/* Karala Gallery — client views.
   The photograph is the interface. Frames are numbered like a contact sheet,
   and a selection is drawn around the frame like a china-marker circle. */

.client { min-height: 100vh }

/* Brand bar */
.top { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 20px 24px; position: relative; z-index: 5 }
.with-cover .top { position: absolute; top: 0; left: 0; right: 0; color: #f4f3ef }
.brand { font-size: 16px; font-weight: 500; letter-spacing: 0.01em; text-decoration: none }
.brand img { max-height: 28px; width: auto }
.admin-pill { font-size: 14px; padding: 6px 10px; border: 1px solid currentColor; border-radius: var(--r); text-decoration: none; opacity: 0.85 }

/* Hero: the cover photograph, title set like a lower-third */
.hero { position: relative; padding: 48px 24px 28px }
.hero.has-cover { height: 86svh; min-height: 440px; max-height: 1100px; padding: 0; overflow: hidden; background: #141413; color: #f4f3ef }
.hero-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 1.6s cubic-bezier(0.2, 0.6, 0.2, 1) }
.hero-img.is-in { opacity: 1 }
.hero.has-cover::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(20, 20, 19, 0.45) 0%, rgba(20, 20, 19, 0) 20%),
    linear-gradient(to top, rgba(20, 20, 19, 0.8) 0%, rgba(20, 20, 19, 0.25) 32%, rgba(20, 20, 19, 0) 50%);
}
.hero-text { position: relative; z-index: 2; max-width: 980px }
.hero.has-cover .hero-text { position: absolute; left: 24px; right: 24px; bottom: 36px }
.hero-title { font-size: clamp(36px, 6.2vw, 72px); line-height: 1.02; font-weight: 500; letter-spacing: -0.022em; margin: 0; text-wrap: balance }
.hero-sub { font-size: 18px; line-height: 1.4; margin: 12px 0 0; color: var(--fog) }
.hero.has-cover .hero-sub { color: rgba(244, 243, 239, 0.82) }
.hero-desc { font-size: 16px; line-height: 1.55; margin: 14px 0 0; max-width: 62ch; color: var(--paper) }
.hero.has-cover .hero-desc { color: rgba(244, 243, 239, 0.9) }
.back { display: inline-block; font-size: 14px; margin: 0 0 14px; color: inherit; opacity: 0.85 }

/* Sticky toolbar */
.bar { position: sticky; top: 0; z-index: 30; background: var(--viewing); border-bottom: 1px solid var(--rule) }
.bar-inner { display: flex; align-items: center; gap: 12px 20px; min-height: 62px; padding: 10px 24px; flex-wrap: wrap }
.bar-count { margin: 0 auto 0 0; font-size: 14px; color: var(--fog) }
.bar-title { display: none; color: var(--paper); font-weight: 500; margin-right: 10px }
.bar.is-stuck .bar-title { display: inline }
.bar-filter { display: flex; gap: 4px }
.bar-filter button { background: none; border: 0; padding: 8px 6px; color: var(--fog); font: 500 14px/1 var(--font); cursor: pointer; border-bottom: 2px solid transparent }
.bar-filter button:hover { color: var(--paper) }
.bar-filter button[aria-pressed="true"] { color: var(--paper); border-bottom-color: var(--paper) }

.sel-n.has-sel { color: var(--grease) }
.bar-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center }

.menu { position: relative }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); min-width: 240px; z-index: 40; background: var(--raised); border: 1px solid var(--rule); border-radius: var(--r); padding: 6px; box-shadow: 0 12px 32px var(--shadow) }
.menu-pop a { display: block; padding: 10px 12px; text-decoration: none; font-size: 14px; border-radius: 2px }
.menu-pop a:hover, .menu-pop a:focus-visible { background: var(--panel) }

/* Sub-galleries */
.folders { padding: 28px 24px 4px }
.folders-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px 16px }
.folder { display: block; text-decoration: none }
.folder-img { display: block; aspect-ratio: 3 / 2; background: var(--panel); overflow: hidden }
.folder-img img { width: 100%; height: 100%; object-fit: cover }
.folder-title { display: block; font-weight: 500; margin-top: 10px }
.folder:hover .folder-title { text-decoration: underline; text-underline-offset: 0.18em }
.folder-count { display: block; font-size: 14px; color: var(--fog) }

/* Contact sheet */
.sheet-wrap { padding: 20px 24px 64px }
.sheet { display: flex; flex-wrap: wrap; column-gap: var(--gx, 8px); row-gap: 6px }
.frame { position: relative; margin: 0; flex: none }
.frame-open { position: relative; display: block; width: 100%; padding: 0; border: 0; background: var(--panel); cursor: zoom-in }
.frame-open img { width: 100%; height: 100%; object-fit: cover }
.frame-file { display: grid; place-items: center; height: 100%; color: var(--fog); font-size: 14px; font-weight: 600; letter-spacing: 0.04em; border: 1px solid var(--rule) }
.frame-play { position: absolute; left: 10px; bottom: 10px; width: 28px; height: 28px; color: #fff; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.6)) }
.frame-cap { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 32px; font-size: 12px; color: var(--fog) }
.frame-num { white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.frame.is-sel .frame-num { color: var(--grease) }
.frame-tools { display: flex; align-items: center; gap: 2px; flex: none }
.frame-c { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--fog); padding: 0 6px 0 2px }
.frame-c svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linejoin: round }
.frame-sel, .frame-buy {
  position: relative; width: 30px; height: 30px; padding: 0; border: 0; background: none; cursor: pointer; color: var(--fog);
  display: grid; place-items: center;
}
.frame-sel::before, .frame-buy::before { content: ""; position: absolute; inset: -7px }
.frame-sel svg, .frame-buy svg { width: 22px; height: 22px; overflow: visible }
.frame-sel circle { fill: none; stroke: currentColor; stroke-width: 1.5 }
.frame-sel:hover { color: var(--paper) }
.frame.is-sel .frame-sel { color: var(--grease) }
.frame.is-sel .frame-sel circle { fill: currentColor }
.frame-buy path { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round }
.frame-buy[aria-pressed="true"] { color: var(--paper) }
.frame-buy[aria-pressed="true"] path { fill: currentColor }

/* The selection mark */
.mark { position: absolute; left: -10px; top: -10px; max-width: none; pointer-events: none; overflow: visible; z-index: 2 }
.mark path { fill: none; stroke: var(--grease); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; filter: url(#wax); opacity: 0.94 }
.mark.is-drawing path { transition: stroke-dashoffset 0.42s cubic-bezier(0.35, 0.05, 0.25, 1) }
.defs { position: absolute; width: 0; height: 0; overflow: hidden }

.sheet-empty { color: var(--fog); padding: 24px 0; max-width: 56ch }
.sheet-plain { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px }

.foot { padding: 24px 24px 56px; color: var(--fog); font-size: 14px; border-top: 1px solid var(--rule) }
.foot p { margin: 0 }
.foot a { color: var(--fog); margin-left: 8px }

/* Viewer */
.lb {
  position: fixed; inset: 0; z-index: 100; background: var(--viewing);
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "stage side" "bar bar";
}
.lb-stage { grid-area: stage; position: relative; display: flex; align-items: center; justify-content: center; padding: 56px 80px 16px; min-height: 0; min-width: 0; touch-action: pan-y pinch-zoom }
.lb-img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; user-select: none; -webkit-user-drag: none }
.lb-video { max-width: 100%; max-height: 100%; background: #000 }
.lb-file { text-align: center; color: var(--fog) }
.lb-ext { font-size: 36px; font-weight: 600; letter-spacing: 0.04em; color: var(--paper); margin: 0 0 8px }
.lb-nav { position: absolute; top: 50%; transform: translateY(-60%); width: 64px; height: 120px; display: grid; place-items: center; background: none; border: 0; cursor: pointer; color: var(--paper); opacity: 0.72; z-index: 3 }
.lb-nav:hover { opacity: 1 }
.lb-nav svg, .lb-close svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round }
.lb-prev { left: 6px }
.lb-next { right: 6px }
.lb-close { position: absolute; top: 10px; right: 10px; width: 44px; height: 44px; display: grid; place-items: center; background: none; border: 0; cursor: pointer; color: var(--paper); z-index: 4 }
.lb-bar { grid-area: bar; display: flex; justify-content: space-between; align-items: center; gap: 12px 20px; flex-wrap: wrap; padding: 12px 24px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--rule) }
.lb-meta { display: flex; gap: 16px; align-items: baseline; margin: 0; min-width: 0 }
.lb-num { position: relative; display: inline-block; min-width: 1.5em; text-align: center; font-size: 21px; font-weight: 500 }
.lb-num.is-sel { color: var(--grease) }
.lb-num .mark path { stroke-width: 2.6 }
.lb-name, .lb-pos { font-size: 14px; color: var(--fog); overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.lb-actions { display: flex; gap: 8px; flex-wrap: wrap }
#lb-sel[aria-pressed="true"] { color: var(--grease); border-color: var(--grease) }
#lb-cart[aria-pressed="true"] { background: var(--paper); color: var(--on-paper); border-color: var(--paper) }
.lb-comments {
  grid-area: side; width: 380px; min-height: 0;
  display: flex; flex-direction: column; gap: 12px; padding: 16px 20px 20px;
  background: var(--panel); border-left: 1px solid var(--rule);
}
.lb-c-head { display: flex; justify-content: space-between; align-items: center }
.lb-c-title { font-size: 18px; font-weight: 500; margin: 0 }
.lb-c-close { position: static; margin-right: -10px }
.lb-c-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1 }
.lb-c-list li { padding: 10px 0; border-bottom: 1px solid var(--rule) }
.lb-c-list li.is-studio { border-left: 2px solid var(--fog); padding-left: 10px }
.lb-c-meta { font-size: 14px; margin: 0 0 2px }
.lb-c-meta span { color: var(--fog); margin-left: 6px }
.lb-c-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere }
.lb-c-empty { color: var(--fog); font-size: 14px }
.lb-c-form { display: grid; gap: 8px }
.lb-open { overflow: hidden }

/* Dialogs and drawer */
.dlg { border: 1px solid var(--rule); border-radius: 4px; background: var(--panel); color: var(--paper); padding: 0; width: min(460px, calc(100% - 32px)); box-shadow: 0 24px 60px var(--shadow) }
.dlg::backdrop { background: rgba(10, 10, 10, 0.62) }
.dlg-form { padding: 24px; display: grid; gap: 4px }
.dlg-form > p { color: var(--fog); margin: 0 0 12px }
.dlg-form label { margin-top: 10px }
.dlg-title { font-size: 21px; font-weight: 500; margin: 0 0 8px }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 120; width: min(440px, 100%);
  overflow-y: auto; padding: 22px 24px calc(28px + env(safe-area-inset-bottom));
  background: var(--panel); border-left: 1px solid var(--rule); box-shadow: -20px 0 60px var(--shadow);
}
.drawer-head { display: flex; justify-content: space-between; align-items: center }
.drawer-close { position: static }
.cart-list { list-style: none; margin: 16px 0; padding: 0 }
.cart-list li { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--rule); font-size: 14px }
.cart-list img { width: 64px; height: 48px; object-fit: cover; background: var(--viewing) }
.cart-all { margin: 12px 0 4px }
.cart-hint { font-size: 14px; color: var(--paper) }
.cart-total { display: flex; justify-content: space-between; font-size: 18px; padding: 14px 0; border-top: 1px solid var(--rule); margin: 8px 0 0 }
.cart-sub { font-size: 16px; font-weight: 600; margin: 12px 0 4px }
.cart-form { display: grid; gap: 4px }
.cart-form label { margin-top: 8px }
.cart-pay { display: grid; gap: 8px; margin-top: 16px }
.cart-pay .btn { min-height: 44px }

/* Gate: password, expired, not found, home */
.gate { min-height: 100svh; display: grid; place-items: center; padding: 32px 24px }
.gate-inner { width: min(440px, 100%) }
.gate .brand { display: inline-block; margin: 0 0 56px }
.gate-title { font-size: 36px; line-height: 1.1; font-weight: 500; letter-spacing: -0.015em; margin: 0 0 14px }
.gate-body { color: var(--fog); margin: 0 0 28px }
.gate-form { display: grid; gap: 4px }
.gate-form .btn { margin-top: 16px; justify-self: start; min-height: 44px; padding: 0 20px }
.gate-form label { margin-top: 10px }
.home { align-content: center }
.home-public { width: min(1100px, 100%); margin-top: 48px }

/* Upload link and order pages */
.page-narrow { width: min(760px, 100%); margin: 0 auto; padding: 24px 24px 80px }
.page-title { font-size: 36px; line-height: 1.1; font-weight: 500; letter-spacing: -0.015em; margin: 24px 0 6px }
.page-lede { color: var(--fog); font-size: 18px; margin: 0 0 28px }
.page-narrow .gate-form { max-width: 440px }
.upload-zone { margin: 24px 0 }
.dropzone { border: 1px dashed var(--rule); border-radius: 4px; padding: 36px 24px; text-align: center; cursor: pointer; transition: border-color 0.12s, background-color 0.12s }
.dropzone:hover, .dropzone.is-over { border-color: var(--paper); background: var(--panel) }
.dz-title { margin: 0 0 8px }
.dz-help { color: var(--fog); margin: 0; font-size: 14px }
.up-done { margin: 16px 0 0; padding: 12px 14px; background: var(--panel); border-left: 2px solid var(--paper) }
.up-list { list-style: none; margin: 12px 0 0; padding: 0; font-size: 14px }
.up-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 4px 16px; padding: 8px 0; border-bottom: 1px solid var(--rule); align-items: center }
.up-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.up-size, .up-status { color: var(--fog) }
.up-status.is-done { color: var(--paper) }
.up-status.is-error { color: var(--alert) }
.up-bar { grid-column: 1 / -1; height: 2px; background: var(--rule); overflow: hidden }
.up-bar span { display: block; height: 100%; width: 0; background: var(--paper); transition: width 0.2s linear }
.sent { margin-top: 32px }
.sent-list { list-style: none; padding: 0; margin: 0; font-size: 14px }
.sent-list li { padding: 6px 0; border-bottom: 1px solid var(--rule) }
.notice { padding: 12px 14px; background: var(--panel); border-left: 2px solid var(--paper); max-width: 64ch }
.order-list { list-style: none; margin: 28px 0 0; padding: 0 }
.order-list li { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--rule) }
.order-img img, .order-img .tile-ext { width: 96px; height: 64px; object-fit: cover; background: var(--panel); display: grid; place-items: center; font-size: 12px; color: var(--fog) }
.order-name { overflow-wrap: anywhere; font-size: 14px }
.flashes-client { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 200; width: min(520px, calc(100% - 32px)) }

@media (max-width: 720px) {
  .top { padding: 16px }
  .hero { padding: 32px 16px 20px }
  .hero.has-cover { height: 72svh; min-height: 380px }
  .hero.has-cover .hero-text { left: 16px; right: 16px; bottom: 24px }
  .hero-sub { font-size: 16px }
  .bar-inner { padding: 8px 12px; gap: 8px 12px; min-height: 54px }
  .bar-actions .btn { min-height: 36px; padding: 0 10px }
  .folders { padding: 20px 12px 0 }
  .folders-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 10px }
  .sheet-wrap { padding: 14px 8px 48px }
  .frame-cap { height: 30px }
  .foot { padding: 20px 16px 48px }
  .lb-stage { padding: 52px 0 8px }
  .lb-nav { display: none }
  .lb-bar { padding: 10px 12px calc(12px + env(safe-area-inset-bottom)) }
  .lb-actions { width: 100% }
  .lb-actions .btn { flex: 1 1 auto }
  .lb-comments { position: fixed; left: 0; right: 0; bottom: 0; height: 72%; width: auto; z-index: 8; border-left: 0; border-top: 1px solid var(--rule); box-shadow: 0 -16px 40px var(--shadow) }
  .bar-title { display: none !important }
  .gate-title, .page-title { font-size: 30px }
}
