/*
Theme Name:  Milad Safabakhsh
Theme URI:   https://example.com
Author:      Milad
Author URI:  https://example.com
Description: A minimal photographer portfolio theme with a fixed left sidebar and full-width content area.
Version:     1.0.2
License:     GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags:        photography, portfolio, minimal, sidebar, one-column
Text Domain: milad-theme
*/

/* ─── CSS Custom Properties (defaults — overridden by Customizer & dark mode) ── */
:root {
  --bg:             #d2d2d2;
  --sidebar-bg:     #f8f8f6;
  --sidebar-border: #e0e0de;
  --text:           #111111;
  --text-muted:     #888888;
  --text-faint:     #aaaaaa;
}

/* ─── Reset & Base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
main { display: block; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 10px;
  color: var(--text);
  background: var(--bg);
}

a { color: inherit; text-decoration: none; }
a:hover { opacity: 0.6; }
img { display: block; max-width: 100%; height: auto; }
ul { list-style: none; }

/* ─── Layout ─────────────────────────────────────────────────────────── */
#page {
  display: flex;
  min-height: 100vh;
}

/* On front page, #page itself must be full viewport height */
.home #page,
.front-page #page {
  height: 100vh;
  overflow: hidden;
}

/* ─── Sidebar ────────────────────────────────────────────────────────── */
#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 240px;
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  padding: 0 32px 28px;
  z-index: 150;
  overflow-y: auto;
  transition: background 0.3s, border-color 0.3s;
}

/* Branding */
.site-branding {
  flex-shrink: 0;
  padding-top: 150px; /* Increased to push everything lower on desktop */
}

.site-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  line-height: 1.35;
  color: var(--text);
  margin-bottom: 8px;
}
.site-title a { color: inherit; }

.site-description {
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Spacers */
.sidebar-nav-spacer {
  flex: 1 1 auto;
  min-height: 60px;
  max-height: 160px;
}
.sidebar-bottom-spacer {
  flex: 1 1 auto;
  min-height: 40px;
  max-height: 120px;
}

/* Navigation */
.main-navigation { flex-shrink: 0; }

.main-navigation ul {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.main-navigation ul li a {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
  display: block;
  padding: 2px 0;
  transition: opacity 0.2s;
}
.main-navigation ul li.current-menu-item a,
.main-navigation ul li a:hover { opacity: 0.4; }

/* Social links */
.sidebar-social {
  flex-shrink: 0;
  margin-bottom: 28px;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.sidebar-social a { color: var(--text-muted); transition: opacity 0.2s; }
.sidebar-social a:hover { opacity: 0.5; }
.sidebar-social .sep { margin: 0 3px; color: var(--text-faint); }

/* News widget */
.sidebar-news {
  flex-shrink: 0;
  border-top: 1px solid var(--sidebar-border);
  padding-top: 20px;
  margin-bottom: 20px;
}
.sidebar-news .news-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 7px;
}
.sidebar-news .news-label a {
  color: var(--text);
  border-bottom: 1px solid #ccc;
  transition: border-color 0.2s, opacity 0.2s;
}
.sidebar-news .news-label a:hover { opacity: 0.5; border-color: transparent; }
.sidebar-news .news-desc {
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Footer / copyright */
.sidebar-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--sidebar-border);
  padding-top: 16px;
  font-size: 9px;
  color: var(--text-faint);
  line-height: 1.7;
  letter-spacing: 0.02em;
}
.sidebar-footer a { color: var(--text-faint); }

#milad-dark-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-faint);
  padding: 0;
  margin-bottom: 8px;
  display: block;
  line-height: 1;
  transition: color 0.2s;
}
#milad-dark-toggle:hover { color: var(--text); }

/* ─── Main Content ───────────────────────────────────────────────────── */
#content {
  margin-left: 240px;
  flex: 1;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  transition: background 0.3s;
}

/* Front page: content fills exact viewport, no scroll */
.home #content,
.front-page #content {
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

#content .site-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  min-height: 0;
}

/* ── Homepage Hero — Full Bleed Cover ── */
.home-hero {
  position: relative;
  width: 100%;
  height: 100vh; /* Force exact viewport height */
  display: flex;
  overflow: hidden;
  background-color: var(--bg);
  margin: 0;
  padding: 0;
}

.home-hero img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover !important; /* Force cover to fill all gaps */
  object-position: center; /* Keeps the center of the image in focus */
}

/* ─── Portfolio / Archive Grid ───────────────────────────────────────── */
.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2px;
  padding: 2px;
}

.portfolio-item {
  position: relative;
  overflow: hidden;
  background: #111;
  aspect-ratio: 4/3;
  cursor: pointer;
}
.portfolio-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.4s ease, transform 0.6s ease;
}
.portfolio-item:hover img { opacity: 0.7; transform: scale(1.03); }

.portfolio-item-info {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 16px;
  background: linear-gradient(transparent, rgba(0,0,0,0.6));
  opacity: 0;
  transition: opacity 0.3s ease;
}
.portfolio-item:hover .portfolio-item-info { opacity: 1; }
.portfolio-item-title {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #fff;
  font-weight: 400;
}

/* ─── Single Post / Page ─────────────────────────────────────────────── */
.entry-wrapper {
  max-width: 680px;
  margin: 60px 60px;
  padding-bottom: 80px;
}
.entry-header { margin-bottom: 32px; }
.entry-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.3;
  color: var(--text);
  margin-bottom: 8px;
}
.entry-meta {
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.entry-content {
  font-size: 12px;
  line-height: 1.75;
  color: #333;
}
.entry-content p { margin-bottom: 1.4em; }
.entry-content h2 { font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 0.8em; margin-top: 2em; font-weight: 700; }
.entry-content h3 { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 0.6em; margin-top: 1.6em; font-weight: 700; }
.entry-content img { margin: 2em 0; }
.entry-content a { border-bottom: 1px solid #aaa; padding-bottom: 1px; }
.entry-content a:hover { border-color: #111; opacity: 1; }
.entry-content blockquote {
  border-left: 2px solid var(--text);
  padding-left: 20px;
  margin: 1.6em 0;
  font-style: italic;
  color: #555;
}

/* ─── About Page ─────────────────────────────────────────────────────── */
.about-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  min-height: 100vh;
}
.about-image {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}
.about-image img { width: 100%; height: 100%; object-fit: cover; }
.about-text { padding: 60px 50px; }

/* ─── Single Portfolio Item ──────────────────────────────────────────── */
.single-portfolio-image {
  width: 100%;
  max-height: 90vh;
  object-fit: contain;
  background: #111;
}
.single-portfolio-meta { padding: 30px 60px; }

/* ─── 404 ────────────────────────────────────────────────────────────── */
.not-found-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  flex-direction: column;
  gap: 16px;
}
.not-found-wrapper .code {
  font-size: 80px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ccc;
}
.not-found-wrapper .message {
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ─── Pagination ─────────────────────────────────────────────────────── */
.pagination {
  padding: 40px 60px;
  display: flex;
  gap: 8px;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.pagination a, .pagination span {
  padding: 4px 8px;
  border: 1px solid #bbb;
  color: #555;
  transition: all 0.2s;
}
.pagination a:hover { background: #111; color: #fff; border-color: #111; opacity: 1; }
.pagination .current { background: #111; color: #fff; border-color: #111; }

/* ════════════════════════════════════════════════════════════
   MOBILE  (≤ 768px)
   Sidebar is fully hidden. A fixed top bar + hamburger button
   opens a fullscreen menu overlay with all content.
   ════════════════════════════════════════════════════════════ */

/* ─── Hamburger button (hidden on desktop) ───────────────────────────── */
.mob-hamburger {
  display: none;
  position: fixed;
  top: 14px;
  left: 16px;
  z-index: 600;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.mob-hamburger span {
  display: block;
  width: 22px;
  height: 1.5px;
  background: var(--text);
  transition: transform 0.3s ease, opacity 0.3s ease, background 0.3s;
  transform-origin: center;
}
/* X state */
.mob-hamburger.is-active span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.mob-hamburger.is-active span:nth-child(2) { opacity: 0; }
.mob-hamburger.is-active span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }
/* When menu is open, force lines white (menu bg is dark) */
.mob-hamburger.is-active span { background: #fff; }

/* ─── Fixed top bar (hidden on desktop) ─────────────────────────────── */
.mob-topbar {
  display: none;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 64px;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--sidebar-border);
  z-index: 500;
  transition: background 0.3s, border-color 0.3s;
}
.mob-topbar-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text);
}
.mob-topbar-title a { color: inherit; }

/* ─── Fullscreen menu overlay ────────────────────────────────────────── */
.mob-menu {
  display: none; /* JS sets display:flex when mobile detected */
  position: fixed;
  inset: 0;
  z-index: 550;
  background: #0d0d0d;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 80px 40px 60px;
}
.mob-menu.is-open {
  opacity: 1;
  pointer-events: all;
}

/* Nav links */
.mob-menu-nav {
  list-style: none;
  margin: 0 0 48px;
  padding: 0;
  text-align: center;
}
.mob-menu-nav li { margin: 0; }
.mob-menu-nav li a {
  display: block;
  font-size: 28px;
  font-weight: 300;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  padding: 14px 0;
  transition: opacity 0.2s;
  line-height: 1.1;
}
.mob-menu-nav li a:hover,
.mob-menu-nav li.current-menu-item a { opacity: 0.35; }

/* Divider */
.mob-menu-divider {
  width: 32px;
  height: 1px;
  background: rgba(255,255,255,0.15);
  margin: 0 auto 36px;
}

/* Social links */
.mob-menu-social {
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  text-align: center;
  margin-bottom: 24px;
}
.mob-menu-social a {
  color: rgba(255,255,255,0.4);
  transition: color 0.2s;
}
.mob-menu-social a:hover { color: rgba(255,255,255,0.8); }
.mob-menu-social .sep { margin: 0 6px; }

/* Footer text */
.mob-menu-footer {
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.2);
  text-align: center;
  line-height: 1.8;
}
.mob-menu-footer a { color: rgba(255,255,255,0.2); }

/* Staggered link entrance animation */
.mob-menu.is-open .mob-menu-nav li {
  animation: mobLinkIn 0.45s ease both;
}
.mob-menu.is-open .mob-menu-nav li:nth-child(1) { animation-delay: 0.05s; }
.mob-menu.is-open .mob-menu-nav li:nth-child(2) { animation-delay: 0.10s; }
.mob-menu.is-open .mob-menu-nav li:nth-child(3) { animation-delay: 0.15s; }
.mob-menu.is-open .mob-menu-nav li:nth-child(4) { animation-delay: 0.20s; }
.mob-menu.is-open .mob-menu-nav li:nth-child(5) { animation-delay: 0.25s; }
.mob-menu.is-open .mob-menu-nav li:nth-child(6) { animation-delay: 0.30s; }
@keyframes mobLinkIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Responsive: activate mobile layout ────────────────────────────── */
@media (max-width: 1024px) {

  /* Hide desktop sidebar completely */
  #sidebar { display: none !important; }

  /* Remove sidebar margin, push below top bar */
  #content {
    margin-left: 0;
    padding-top: 64px;
  }

  /* Show hamburger + top bar */
  .mob-hamburger { display: flex; }
  .mob-topbar    { display: flex; }
  .mob-menu      { display: flex; }

  /* Hero fills full viewport on mobile */
  .home-hero { min-height: 100svh; }
  .home #content, .front-page #content { height: 100svh; }
  .home-hero img { height: 100%; object-fit: contain !important; }

  /* Layout adjustments */
  .about-layout  { grid-template-columns: 1fr; }
  .about-image   { position: relative; height: 56vw; }
  .entry-wrapper { margin: 32px 20px; padding-bottom: 48px; }
  .single-portfolio-meta { padding: 20px; }
  .pagination    { padding: 30px 20px; }

  .portfolio-grid { grid-template-columns: 1fr 1fr; gap: 2px; }
}

@media (max-width: 480px) {
  .portfolio-grid { grid-template-columns: 1fr; gap: 1px; padding: 1px; }
  .entry-wrapper  { margin: 24px 16px; }
  .mob-menu-nav li a { font-size: 22px; padding: 11px 0; }
}

/* ─── Dark mode adjustments for mobile chrome ────────────────────────── */
[data-theme="dark"] .mob-topbar {
  background: var(--sidebar-bg);
  border-color: var(--sidebar-border);
}
[data-theme="dark"] .mob-topbar-title { color: var(--text); }
[data-theme="dark"] .mob-hamburger span { background: var(--text); }
[data-theme="dark"] .mob-hamburger.is-active span { background: #fff; }
