/* ============================================================
   PHOTOAURA — app.css
   Dark photographer's tool. Photo is the hero; controls live in
   a bottom sheet on mobile, a side rail on desktop.
   ============================================================ */

:root {
  --header-h: 52px;
  --peek: 128px;               /* sheet height when collapsed */
  --sheet-radius: 20px;
}

body { min-height: 100dvh; overscroll-behavior-y: none; }
body.busy .stage::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- header / footer -------------------------------- */
.app-header {
  display: flex; align-items: baseline; gap: 0.7rem;
  height: var(--header-h);
  padding: 0 1.15rem;
  position: relative; z-index: 2;
}
.wordmark { font-family: var(--font-head); font-weight: 700; font-size: 1.1rem; letter-spacing: -0.02em; }
.wordmark span { color: var(--accent); margin-left: 1px; }
.app-tag { font-family: var(--font-mono); font-size: 0.66rem; color: var(--ink-dim); }
.app-footer {
  padding: 2rem 1.15rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
  font-family: var(--font-mono); font-size: 0.66rem; color: var(--ink-dim);
  text-align: center; line-height: 1.7;
}
.app-footer span { color: var(--ink); font-weight: 600; }
.app-footer a { color: var(--accent); }
body.has-photo .app-footer { display: none; }
body.has-photo .app-header { display: none; }

/* ---- floating glass control bar (editor) ------------ */
.float-bar {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 12px; right: 12px;
  z-index: 40;
  height: 46px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 6px 0 15px;
  border-radius: 23px;
  background: rgba(16, 18, 22, 0.5);
  -webkit-backdrop-filter: blur(22px) saturate(1.6);
  backdrop-filter: blur(22px) saturate(1.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.32);
}
.float-brand {
  font-family: var(--font-head); font-weight: 700; font-size: 0.9rem;
  letter-spacing: -0.02em; color: rgba(255,255,255,0.92);
}
.float-brand span { color: var(--accent); margin-left: 1px; }

.float-actions { display: flex; align-items: center; gap: 2px; }
.fbtn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: transparent; color: #fff; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.14s;
}
.fbtn:hover { background: rgba(255,255,255,0.12); }
.fbtn:active { background: rgba(255,255,255,0.18); }
.fbtn svg { width: 20px; height: 20px; }
.fbtn .i-ok { display: none; }
.fbtn.done .i-dl { display: none; }
.fbtn.done .i-ok { display: block; color: var(--ok); }
.fbtn-sep { width: 1px; height: 20px; background: rgba(255,255,255,0.16); margin: 0 2px; }

.fmenu {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 232px;
  padding: 6px;
  border-radius: 15px;
  background: rgba(24, 26, 31, 0.72);
  -webkit-backdrop-filter: blur(24px) saturate(1.7);
  backdrop-filter: blur(24px) saturate(1.7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  animation: fmenu-in 0.14s ease-out;
}
@keyframes fmenu-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }
.fmenu-item {
  display: flex; align-items: center; gap: 0.7rem; width: 100%;
  padding: 0.6rem 0.7rem; border: 0; border-radius: 10px;
  background: transparent; color: var(--ink);
  font-size: 0.9rem; font-weight: 500; text-align: left;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.fmenu-item svg { width: 18px; height: 18px; color: var(--ink-dim); flex-shrink: 0; }
.fmenu-item:hover { background: rgba(255,255,255,0.08); }
.fmenu-sep { display: block; height: 1px; background: rgba(255,255,255,0.1); margin: 5px 8px; }

/* ============================================================
   HOME / LANDING
   ============================================================ */
body:not(.has-photo) { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
.btn-lg { min-height: 54px; font-size: 1rem; border-radius: var(--radius); }

.home { max-width: 960px; margin: 0 auto; padding: 1.5rem 1.15rem 3rem; overflow-x: clip; }

.home-eyebrow {
  display: inline-block;
  font-family: var(--font-mono); font-size: 0.68rem;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-ink);
  margin-bottom: 0.9rem;
}

/* ---- hero ---- */
.home-hero { padding: 1.5rem 0 2.5rem; }
.home-hero h1 {
  font-size: clamp(2.1rem, 8vw, 3.1rem);
  line-height: 1.04; letter-spacing: -0.03em;
  margin-bottom: 0.9rem;
}
.home-hero h1 em { font-style: normal; color: var(--accent); }
.home-lead { color: var(--ink-dim); font-size: 1.02rem; line-height: 1.6; max-width: 42ch; margin-bottom: 1.6rem; }
.home-hero-cta { padding-inline: 1.7rem; }
.home-drop { font-family: var(--font-mono); font-size: 0.72rem; color: var(--ink-dim); margin-top: 0.85rem; }

/* ---- fanned mock cards ---- */
.home-fan { display: flex; justify-content: center; align-items: center; margin-top: 2.25rem; padding: 12px 20px; }
.mock {
  width: 40%; max-width: 146px; aspect-ratio: 3 / 4;
  border-radius: 13px; overflow: hidden;
  box-shadow: 0 16px 34px rgba(0,0,0,0.5);
  flex-shrink: 0;
}
.mock + .mock { margin-left: -26px; }
.mock--frame  { transform: rotate(-6deg) translateY(6px); z-index: 1; }
.mock--bar    { transform: translateY(-12px); z-index: 3; }
.mock--block  { transform: rotate(6deg) translateY(6px); z-index: 1; }
.mock-photo {
  width: 100%; height: 100%;
  background:
    radial-gradient(130% 90% at 18% 8%, #6a4f2e 0%, transparent 55%),
    radial-gradient(120% 100% at 92% 96%, #2a4c58 0%, transparent 52%),
    linear-gradient(#1c1f23, #101216);
  position: relative;
}
.mock-photo--b { background:
    radial-gradient(120% 85% at 35% 18%, #9c6a3c 0%, transparent 62%),
    linear-gradient(#241d18, #0f1114); }
.mock-photo--c { background:
    radial-gradient(130% 110% at 72% 78%, #356070 0%, transparent 58%),
    radial-gradient(90% 70% at 20% 15%, #5a4a34 0%, transparent 60%),
    linear-gradient(#171b1e, #0d0f12); }
.mock b { display: block; font-family: var(--font-mono); font-weight: 600; color: #fff; font-size: 0.52rem; white-space: nowrap; }
.mock-tick { display: block; width: 18px; height: 2px; background: var(--accent); margin-bottom: 4px; }

/* frame style */
.mock--frame .mock-photo { height: 74%; margin: 8% 8% 0; width: auto; border-radius: 3px; }
.mock--frame { background: #f2efe8; }
.mock--frame .mock-cap { padding: 6px 9px; }
.mock--frame .mock-cap b { color: #14150f; }
.mock--frame .mock-tick { background: var(--accent); }

/* bar style */
.mock-scrim {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 22px 9px 8px;
  background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,0.82));
}
/* block style */
.mock-blk {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; text-align: center;
  background: rgba(6,7,9,0.5);
}
.mock-rule { display: block; width: 22px; height: 2px; background: var(--accent); }

/* ---- tools ---- */
.home-sec-head { margin-bottom: 1.5rem; }
.home-sec-head h2 { font-size: clamp(1.3rem, 4.5vw, 1.7rem); letter-spacing: -0.02em; }
.home-tools, .home-why { padding: 2.5rem 0; border-top: 1px solid var(--line); }

.tool-grid { display: grid; grid-template-columns: 1fr; gap: 0.85rem; }
.tool-card {
  text-align: left;
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem;
  padding: 1.25rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--ink);
}
.tool-card--live { cursor: pointer; -webkit-tap-highlight-color: transparent; transition: border-color 0.15s, transform 0.12s; }
.tool-card--live:hover { border-color: var(--accent); }
.tool-card--live:active { transform: scale(0.99); }
.tool-card--soon { opacity: 0.6; }
.tool-icon {
  width: 40px; height: 40px; border-radius: 11px;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--accent);
}
.tool-icon svg { width: 21px; height: 21px; }
.tool-card h3 { font-size: 1.05rem; letter-spacing: -0.01em; }
.tool-card p { font-size: 0.88rem; color: var(--ink-dim); line-height: 1.55; }
.tool-open { font-family: var(--font-mono); font-size: 0.78rem; font-weight: 600; color: var(--accent); margin-top: 0.15rem; }
.tool-badge {
  font-family: var(--font-mono); font-size: 0.64rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-dim); border: 1px solid var(--line); border-radius: var(--radius-pill);
  padding: 0.2rem 0.6rem; margin-top: 0.15rem;
}

/* ---- why ---- */
.home-why { display: grid; gap: 1.25rem; }
.why-item { display: flex; gap: 0.9rem; }
.why-icon { flex-shrink: 0; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--accent); }
.why-icon svg { width: 18px; height: 18px; }
.why-item strong { display: block; font-size: 0.94rem; margin-bottom: 0.15rem; }
.why-item span { font-size: 0.86rem; color: var(--ink-dim); line-height: 1.55; }

/* ---- floating mobile CTA ---- */
.home-cta {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  padding: 0.8rem 1rem calc(0.8rem + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
body.has-photo .home-cta { display: none; }
.home-hero-cta { display: none; }   /* mobile: use the floating bar */

/* ---- home on wider screens ---- */
@media (min-width: 760px) {
  body:not(.has-photo) { padding-bottom: 0; }
  .home-cta { display: none; }
  .home-hero-cta { display: inline-flex; }
  .home { padding: 2.5rem 2rem 4rem; }

  .home-hero {
    display: grid; grid-template-columns: 1.1fr 0.9fr; align-items: center; gap: 2.5rem;
    padding: 2.5rem 0 3.5rem;
  }
  .home-fan { margin-top: 0; }
  .mock { max-width: 190px; }

  .tool-grid { grid-template-columns: repeat(3, 1fr); gap: 1rem; }
  .home-why { grid-template-columns: repeat(3, 1fr); gap: 1.75rem; }
}

/* ---- stage / canvas ------------------------------- */
.stage {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: var(--peek);
  display: grid; place-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 64px) 0.85rem 0.85rem;
  background: var(--bg);
  transition: bottom 0.30s cubic-bezier(.32,.72,0,1);
}
body[data-snap="peek"] .stage { bottom: var(--peek); }
body[data-snap="mid"]  .stage { bottom: 46dvh; }
body[data-snap="full"] .stage { bottom: 88dvh; }
.canvas-wrap { position: relative; display: inline-flex; max-width: 100%; max-height: 100%; }
#canvas {
  max-width: 100%; max-height: 100%;
  width: auto; height: auto;
  border-radius: 4px; box-shadow: var(--shadow-md);
  touch-action: none;
}
.stage.grabbable #canvas { cursor: grab; }
.stage.grabbing #canvas { cursor: grabbing; }

/* story safe-zone guide */
.safe-guide { display: none; position: absolute; inset: 0; pointer-events: none; }
.stage.show-safe .safe-guide { display: block; }
.safe-guide::before, .safe-guide::after {
  content: ""; position: absolute; left: 0; right: 0;
  background: repeating-linear-gradient(45deg, rgba(224,101,93,0.14) 0 8px, transparent 8px 16px);
  border-block: 1px dashed rgba(224,101,93,0.7);
}
.safe-guide::before { top: 0; height: 13%; }
.safe-guide::after { bottom: 0; height: 15%; }
.safe-guide span {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-family: var(--font-mono); font-size: 0.55rem; letter-spacing: 0.05em;
  color: rgba(255,255,255,0.85); background: rgba(224,101,93,0.55);
  padding: 1px 5px; border-radius: 3px; white-space: nowrap;
}
.safe-guide span:first-child { top: calc(13% - 9px); }
.safe-guide span:last-child { bottom: calc(15% - 9px); }

/* centre snap guides */
.snap-guide { position: absolute; inset: 0; pointer-events: none; }
.snap-guide i { position: absolute; background: var(--accent); opacity: 0; transition: opacity 0.08s ease; box-shadow: 0 0 6px rgba(240,166,58,0.7); }
.snap-guide i.v { left: 50%; top: 0; bottom: 0; width: 1px; transform: translateX(-0.5px); }
.snap-guide i.h { top: 50%; left: 0; right: 0; height: 1px; transform: translateY(-0.5px); }
.snap-guide.snap-v i.v { opacity: 0.92; }
.snap-guide.snap-h i.h { opacity: 0.92; }

/* ============================================================
   BOTTOM SHEET (mobile)
   ============================================================ */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: 92dvh;
  z-index: 30;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-radius: var(--sheet-radius) var(--sheet-radius) 0 0;
  box-shadow: 0 -14px 44px rgba(0,0,0,0.55);
  transform: translateY(var(--sheet-y, calc(100% - var(--peek))));
  transition: transform 0.30s cubic-bezier(.32,.72,0,1);
}
.sheet.dragging { transition: none; }
.sheet[data-snap="peek"] { --sheet-y: calc(100% - var(--peek)); --sheet-vis: var(--peek); }
.sheet[data-snap="mid"]  { --sheet-y: 42dvh; --sheet-vis: 50dvh; }
.sheet[data-snap="full"] { --sheet-y: 0;     --sheet-vis: 92dvh; }

.sheet-grip {
  flex-shrink: 0;
  padding: 0.6rem 1rem 0.5rem;
  cursor: grab; touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.sheet.dragging .sheet-grip { cursor: grabbing; }
.grip-bar { display: block; width: 40px; height: 4px; border-radius: 999px; background: var(--line); margin: 0 auto; }

.sheet-body {
  flex: 1 1 auto; min-height: 0;
  /* clamp the scroll viewport to the part of the sheet that's actually on screen,
     so content below the fold is reachable at every snap */
  max-height: calc(var(--sheet-vis, 50dvh) - 40px);
  overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0.35rem 1.05rem calc(2.5rem + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 1.4rem;
}

/* ---- control groups ------------------------------- */
.exif-note {
  font-family: var(--font-mono); font-size: 0.7rem; color: var(--ink-dim);
  padding: 0.5rem 0.7rem; background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.exif-note.warn { color: var(--accent-ink); border-color: var(--accent-dark); }

.group { display: flex; flex-direction: column; gap: 0.9rem; }
.group-title {
  font-family: var(--font-head); font-weight: 700; font-size: 0.82rem;
  letter-spacing: 0.02em; color: var(--ink);
  padding-bottom: 0.45rem; border-bottom: 1px solid var(--line);
  display: flex; align-items: baseline; justify-content: space-between;
}
.group-hint { font-family: var(--font-mono); font-weight: 400; font-size: 0.6rem; color: var(--ink-dim); letter-spacing: 0; }

.ctl { display: flex; flex-direction: column; gap: 0.4rem; }
.ctl--inline { flex-direction: row; align-items: center; justify-content: space-between; }
.ctl-inline { display: flex; gap: 0.7rem; }
.ctl--half { flex: 1; min-width: 0; }
.ctl-label {
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.02em;
  color: var(--ink-dim);
}
.mini-note { font-family: var(--font-mono); font-size: 0.6rem; color: var(--ink-dim); opacity: 0.8; }

/* segmented — horizontal scroll strip */
.segmented {
  display: flex; flex-wrap: nowrap; gap: 3px;
  padding: 3px; border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
  scroll-snap-type: x proximity;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented button {
  flex: 0 0 auto; scroll-snap-align: start; white-space: nowrap;
  min-height: 34px; padding: 0.4rem 0.8rem;
  border: 0; border-radius: 6px; background: transparent;
  color: var(--ink-dim); font-size: 0.82rem; font-weight: 600;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: color 0.12s, background 0.12s;
}
.segmented button[aria-pressed="true"] {
  background: var(--surface-2); color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,0.35);
}
/* make short groups fill the width instead of hugging left */
#photo-seg, #bg-seg, #size-seg, #theme-seg { }
#photo-seg button, #bg-seg button, #size-seg button, #theme-seg button { flex: 1 1 auto; text-align: center; }

.select {
  width: 100%; min-height: 42px;
  padding: 0.5rem 0.7rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 0.88rem;
}
.select:focus { outline: none; border-color: var(--accent); }

/* inline toggle row */
.ctl-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  min-height: 44px; cursor: pointer; -webkit-tap-highlight-color: transparent;
  font-size: 0.86rem; color: var(--ink);
}
.ctl-toggle input { position: absolute; opacity: 0; pointer-events: none; }

/* position grid */
.pos-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; width: 128px; }
.pos-cell {
  aspect-ratio: 1; border: 1px solid var(--line); background: var(--bg);
  border-radius: 6px; cursor: pointer; display: grid; place-items: center; padding: 0;
  -webkit-tap-highlight-color: transparent;
}
.pos-cell span { width: 7px; height: 7px; border-radius: 2px; background: var(--ink-dim); transition: background 0.12s; }
.pos-cell[aria-pressed="true"] { border-color: var(--accent); background: var(--surface-2); }
.pos-cell[aria-pressed="true"] span { background: var(--accent); }

/* accent swatches */
.swatches { display: flex; gap: 0.45rem; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--line); cursor: pointer; padding: 0;
  -webkit-tap-highlight-color: transparent;
}
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); border-color: var(--ink); }

/* detail fields */
.fields { display: flex; flex-direction: column; }
.field-row {
  display: grid; grid-template-columns: auto 1fr; align-items: center;
  gap: 0.7rem; padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
  transition: opacity 0.15s;
}
.field-row:last-child { border-bottom: 0; }
.field-row .toggle { grid-column: 1; }
.field-row .field-row-input { grid-column: 2; }
.field-row:has(input[type="checkbox"]:not(:checked)) { opacity: 0.42; }
.field-row-label { font-size: 0.88rem; font-weight: 500; }
.field-row-input {
  min-height: 40px; padding: 0.45rem 0.6rem;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-size: 0.8rem;
}
.field-row-input:focus { outline: none; border-color: var(--accent); }

/* ---- result sheet ------------------------------- */
.result-sheet {
  position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,0.78);
  display: flex; align-items: center; justify-content: center; padding: 1.25rem;
}
.result-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.15rem; max-width: 420px; width: 100%;
  display: flex; flex-direction: column; gap: 0.9rem; max-height: 90dvh; overflow: auto;
}
.result-card p { font-size: 0.85rem; color: var(--ink-dim); text-align: center; }
.result-card img { width: 100%; border-radius: var(--radius-sm); }

/* ============================================================
   DESKTOP — side rail instead of a sheet
   ============================================================ */
@media (min-width: 900px) {
  :root { --header-h: 60px; }

  .app-header { max-width: 1280px; margin: 0 auto; width: 100%; border-bottom: 1px solid var(--line); }
  .empty { min-height: calc(100dvh - var(--header-h)); }
  .empty-inner { max-width: 460px; }

  #editor { display: block; }
  .stage, body[data-snap] .stage {
    top: 0; bottom: 0; right: 420px; left: 0;
    padding: 78px 2rem 2rem;
    background: radial-gradient(130% 120% at 50% 0%, var(--surface) 0%, var(--bg) 68%);
    border-right: 1px solid var(--line);
    transition: none;
  }

  .float-bar { left: 16px; right: calc(420px + 16px); top: 14px; max-width: 720px; }

  .sheet {
    top: 0; bottom: 0; left: auto; right: 0;
    width: 420px; height: auto;
    transform: none !important;
    border: 0; border-radius: 0;
    box-shadow: none;
    background: var(--surface);
  }
  .sheet-grip { display: none; }
  .sheet-body { max-height: none; padding: 1.4rem 1.25rem 2rem; gap: 1.5rem; }
}
