/* =========================================================
   Khai Mohd — Editorial Photography Portfolio
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=Archivo:wght@400;500;600;700&family=Archivo+Black&display=swap');

:root{
  --paper: #F4F1E9;
  --paper-2: #EAE6DA;
  --ink: #201F26;
  --ink-soft: #55535C;
  --line: #D9D3C3;
  --rust: #B25B3E;
  --white: #FBFAF7;

  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Archivo', Helvetica, Arial, sans-serif;
  --logo-font: 'Archivo Black', Helvetica, Arial, sans-serif;

  --sidebar-w: 230px;
  --gutter: 16px;
}

*{ box-sizing: border-box; }

body{
  margin:0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img{ display:block; max-width:100%; }
a{ color: inherit; text-decoration: none; }
::selection{ background: var(--rust); color: var(--white); }
:focus-visible{ outline: 2px solid var(--rust); outline-offset: 3px; }

.visually-hidden{
  position:absolute; width:1px; height:1px; overflow:hidden;
  clip:rect(0,0,0,0); white-space:nowrap; border:0; padding:0; margin:-1px;
}

/* ---------------------------------------------------------
   LAYOUT SHELL
--------------------------------------------------------- */
.shell{
  display:flex;
  align-items:stretch;
  min-height:100vh;
}

/* ---------------------------------------------------------
   SIDEBAR
--------------------------------------------------------- */
.sidebar{
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  align-self: flex-start;
  position: sticky;
  top:0;
  height:100vh;
  padding: 38px 26px 26px;
  display:flex;
  flex-direction:column;
  justify-content:space-between;
}

.logo{
  font-family: var(--logo-font);
  font-size: 26px;
  line-height: 0.86;
  letter-spacing: -0.01em;
  text-transform:uppercase;
}
.logo a{ display:block; }
.logo .line2{ display:block; }

.nav{
  margin-top: 44px;
  display:flex;
  flex-direction:column;
  gap: 15px;
}

.nav a{
  font-size: 13px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--ink);
  width: fit-content;
}
.nav a:hover{ color: var(--rust); }
.nav a.active{ color: var(--rust); }

.sidebar-footer{ margin-top: 40px; }

/* Email and Instagram sidebar buttons */
.email-btn,
.insta-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 75%;
  border: 1px solid var(--ink);
  padding: 9px 16px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--ink);
  transition: background .25s ease, color .25s ease;
}

.email-btn {
  margin-bottom: 10px;
}

.email-btn svg,
.insta-btn svg {
  flex: 0 0 auto;
}

.email-btn:hover,
.insta-btn:hover {
  background: var(--ink);
  color: var(--paper);
}

@media (max-width: 900px) {
  .mobile-nav .email-btn,
  .mobile-nav .insta-btn {
    width: 160px;
  }
}

/* mobile topbar controls (hidden on desktop) */
.topbar{ display:none; }
.menu-toggle{ display:none; }
.mobile-nav{ display:none; }

/* ---------------------------------------------------------
   MAIN CONTENT
--------------------------------------------------------- */
.main{
  flex:1;
  min-width:0;
  display:flex;
  flex-direction:column;
}

.page-head{
  padding: 38px 40px 6px 0;
  max-width: 760px;
}
.page-head .eyebrow{
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--rust);
  margin: 0 0 8px;
}
.page-head h1{
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.1;
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}
.page-head p{
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink-soft);
  max-width: 56ch;
  margin: 0;
}

/* ---------------------------------------------------------
   GALLERY — JS masonry.
   script.js splits the images into .gallery-col columns,
   placing each image (in HTML order) into the shortest column.
   Images keep their native aspect ratio — no cropping.
   The gallery stays hidden until the layout is built (.is-ready)
   so there's no flash of unstyled images.
--------------------------------------------------------- */
.gallery {
  display: flex;
  align-items: flex-start;
  gap: var(--gutter);
  padding: var(--gutter);
  opacity: 0;
  transition: opacity .3s ease;
}
.gallery.is-ready{ opacity: 1; }

.gallery-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gutter);
}

.grid-item {
  position: relative;
  display: block;
  overflow: hidden;
  background: var(--paper-2);
  min-width: 0;
  -webkit-tap-highlight-color: transparent;  /* removes the blue/grey flash on touch */
  -webkit-user-select: none;
  user-select: none;                         /* stops long-press selecting the image */
}

.grid-item img {
  width: 100%;
  height: auto;
  display: block;
}

/* flat white layer laid over the image at low opacity — not a brightness filter */
.grid-item::before{
  content:"";
  position:absolute;
  inset:0;
  background: rgba(255,255,255,0.55);
  opacity:0;
  transition: opacity .35s ease;
  pointer-events:none;
  z-index:1;
}
.grid-item:focus-visible::before{ opacity:1; }

/* magnifier icon on hover */
.grid-item::after{
  content:"";
  position:absolute;
  top:50%; left:50%;
  width:38px; height:38px;
  transform: translate(-50%,-50%) scale(0.8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23B25B3E' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cline x1='15.3' y1='15.3' x2='21' y2='21'/%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:center;
  background-size:contain;
  opacity:0;
  transition: opacity .35s ease, transform .35s ease;
  pointer-events:none;
  z-index:2;
}
.grid-item:focus-visible::after{
  opacity:1;
  transform: translate(-50%,-50%) scale(1);
}

/* Hover overlay only on devices that truly hover (mouse / trackpad).
   Touch screens treat a press as "hover", which covered the image while scrolling. */
@media (hover: hover) and (pointer: fine){
  .grid-item:hover::before{ opacity:1; }
  .grid-item:hover::after{
    opacity:1;
    transform: translate(-50%,-50%) scale(1);
  }
}

/* ---------------------------------------------------------
   ABOUT PAGE
--------------------------------------------------------- */
.about-wrap{
  flex: 1 0 auto;                       /* fills the screen height */
  padding: 38px 40px 40px 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(40px, 5vw, 80px);
  align-items: center;
}
.about-text h1{
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(34px, 4.2vw, 62px);
  line-height: 1.02;
  letter-spacing: -0.02em;
  margin: 0 0 clamp(22px, 2.5vw, 36px);
}
.about-text p{
  font-size: clamp(16px, 1.45vw, 20px);
  line-height: 1.75;
  color: var(--ink-soft);
  margin: 0 0 18px;
  max-width: 52ch;
}

.about-img{
  position: relative;
  align-self: stretch;                  /* image runs the full height of the row */
  min-height: 480px;
  overflow: hidden;
  background: var(--paper-2);
}
.about-img img{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* contact row — columns line up with the text/image above */
.inquiries{
  padding: 0 40px 56px 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(40px, 5vw, 80px);
}
.inquiries > div{
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.inquiries h2{
  font-family: var(--sans);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--rust);
  margin: 0 0 10px;
}
.inquiries p{
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(18px, 1.9vw, 26px);
  color: var(--ink);
  overflow-wrap: anywhere;
}
.inquiries a{
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: var(--line);
  transition: color .2s ease, text-decoration-color .2s ease;
}
.inquiries a:hover{ color: var(--rust); text-decoration-color: var(--rust); }

/* ---------------------------------------------------------
   FOOTER
--------------------------------------------------------- */
.site-footer {
  padding: 20px 40px 30px 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.site-footer a:hover{ color: var(--rust); }

/* ---------------------------------------------------------
   RESPONSIVE
   (Gallery column counts are handled in script.js:
    3 columns above 1080px, 2 up to 1080px, 1 up to 480px.
    Keep those breakpoints in sync with getColCount().)
--------------------------------------------------------- */
@media (max-width: 900px){
  :root{ --gutter: 6px; }

  .shell{ flex-direction: column; }
  .sidebar{ display:none; }

  .topbar{
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top:0;
    background: var(--paper);
    z-index: 50;
    transform: translateY(0);
    transition: transform .3s ease;
  }
  .topbar.topbar-hidden{
    transform: translateY(-100%);
  }
  .topbar .logo{ font-size: 17px; }

  .menu-toggle{
    display:flex;
    flex-direction:column;
    gap:5px;
    width: 24px;
    background:none;
    border:none;
    cursor:pointer;
    padding: 6px 0;
  }
  .menu-toggle span{
    display:block;
    height:1.5px;
    background: var(--ink);
    width:100%;
    transition: transform .3s ease, opacity .3s ease;
  }
  body.nav-open .menu-toggle span:nth-child(1){ transform: translateY(6.5px) rotate(45deg); }
  body.nav-open .menu-toggle span:nth-child(2){ opacity:0; }
  body.nav-open .menu-toggle span:nth-child(3){ transform: translateY(-6.5px) rotate(-45deg); }

  .mobile-nav{
    position: fixed;
    inset: 0;
    top: 57px;
    background: var(--paper);
    z-index: 49;
    padding: 26px 22px;
    display:flex;
    flex-direction:column;
    justify-content:space-between;
    transform: translateY(-100%);
    opacity:0;
    visibility:hidden;
    transition: transform .38s ease, opacity .3s ease, visibility 0s linear .38s;
    overflow-y:auto;
  }
  body.nav-open .mobile-nav{
    transform: translateY(0);
    opacity:1;
    visibility:visible;
    transition: transform .38s ease, opacity .3s ease;
  }
  .mobile-nav .nav{ margin-top:0; gap:20px; }
  .mobile-nav .nav a{ font-size: 19px; font-family: var(--serif); text-transform:none; letter-spacing:0; }
  .mobile-nav .nav a.active{ color: var(--rust); }

  .page-head{ padding: 26px 20px 4px; }

  .about-wrap{
    grid-template-columns: 1fr;
    padding: 28px 20px 10px;
    gap: 26px;
    align-items: start;
  }
  .about-img{ order:-1; aspect-ratio: 4/3; min-height: 0; }
  .inquiries{ grid-template-columns: 1fr; padding: 10px 20px 44px; gap: 22px; }
  .inquiries > div{ padding-top: 18px; }
  .site-footer {
    padding: 18px 20px 26px;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------------------------------------------------------
   LIGHTBOX
--------------------------------------------------------- */
body.lightbox-open{ overflow: hidden; }

.lightbox-overlay{
  position: fixed;
  inset: 0;
  background: rgba(18,16,13,0.9);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index: 300;
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s ease, visibility 0s linear .3s;
}
.lightbox-overlay.is-open{
  opacity: 1;
  visibility: visible;
  transition: opacity .3s ease;
}

.lightbox-frame{
  background: var(--white);
  padding: 32px;
  max-width: 82vw;
  max-height: 84vh;
  box-shadow: 0 24px 70px rgba(0,0,0,0.4);
  transform: scale(0.97);
  transition: transform .3s ease, opacity .2s ease;
}
.lightbox-frame.is-loading{ opacity: 0; }
.lightbox-overlay.is-open .lightbox-frame{ transform: scale(1); }

.lightbox-stage{
  overflow: hidden;       /* zoomed image is clipped to the photo area, white border stays */
  line-height: 0;
}

.lightbox-frame img{
  display:block;
  max-width: 100%;
  max-height: 76vh;
  width:auto;
  height:auto;
  transform-origin: center center;
  will-change: transform;
  cursor: zoom-in;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}
.lightbox-overlay.is-zoomed .lightbox-frame img{ cursor: grab; }
.lightbox-overlay.is-panning .lightbox-frame img{ cursor: grabbing; }

/* we handle pinch / pan ourselves, so stop the browser scrolling or zooming the page */
.lightbox-overlay{
  touch-action: none;
  overscroll-behavior: contain;
}

/* zoom +/- buttons (desktop / mouse only) */
.lightbox-zoom{
  position: fixed;
  top: 22px;
  left: 22px;
  display: flex;
  gap: 8px;
  z-index: 2;
}
.lightbox-zoom button{
  width: 40px;
  height: 40px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: transparent;
  border: 1px solid rgba(251,250,247,0.5);
  border-radius: 50%;
  color: var(--white);
  cursor: pointer;
  transition: background .25s ease, border-color .25s ease, color .25s ease;
}
.lightbox-zoom button:hover{
  background: var(--white);
  color: var(--ink);
  border-color: var(--white);
}
@media (hover: none){
  .lightbox-zoom{ display:none; }
}

.lightbox-close{
  position: fixed;
  top: 22px;
  right: 22px;
  width: 40px;
  height: 40px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: transparent;
  border: none;
  color: var(--white);
  cursor: pointer;
  z-index: 2;
}
.lightbox-close:hover{ color: var(--rust); }

.lightbox-nav{
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: transparent;
  border: 1px solid rgba(251,250,247,0.5);
  border-radius: 50%;
  color: var(--white);
  cursor: pointer;
  transition: background .25s ease, border-color .25s ease, color .25s ease;
}
.lightbox-nav:hover{
  background: var(--white);
  color: var(--ink);
  border-color: var(--white);
}
.lightbox-prev{ left: 22px; }
.lightbox-next{ right: 22px; }

@media (max-width: 720px){
  .lightbox-frame{ padding: 8px; max-width: 94vw; max-height: 78vh; }
  .lightbox-frame img{ max-height: 70vh; }
  .lightbox-close{ top: 14px; right: 14px; width: 36px; height: 36px; }
  .lightbox-nav{
    top: auto;
    bottom: 26px;
    transform: none;
    width: 42px;
    height: 42px;
  }
  .lightbox-prev{ left: 50%; margin-left: -58px; }
  .lightbox-next{ right: 50%; margin-right: -58px; }
}