/* PuriKura Web Ã¢â‚¬â€ design tokens + layout.
   Colors/spacing are eyeballed from reference/UI/*.png crops, not measured
   off Figma Ã¢â‚¬â€ CLAUDE.md defers to the live Figma frames (node 825:4331 /
   1379:50407) as the source of truth for exact values. */

/* Fonts reused from ../../PuriKura (../../PuriKura/src/css/purikura.css) Ã¢â‚¬â€
   Neulis Cursive for display/headline text, Circular Std for everything
   else, same family names/weights as the booth so the two stay visually
   consistent. */
@font-face {
  font-family: 'Neulis Cursive';
  src: url('../fonts/NeulisCursive-Regular.otf') format('opentype');
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: 'Neulis Cursive';
  src: url('../fonts/neulis-cursive-bold.otf') format('opentype');
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: 'Circular Std';
  src: url('../fonts/CircularStd-Book.otf') format('opentype');
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: 'Circular Std';
  src: url('../fonts/CircularStd-Medium.otf') format('opentype');
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: 'Circular Std';
  src: url('../fonts/CircularStd-Bold.otf') format('opentype');
  font-weight: 700;
  font-display: swap;
}

:root {
  --purple-bg: #5C2D91;
  --purple-primary: #4b2e8f;
  --purple-primary-hover: #3d2575;
  --cream-bg: #f7f2e9;
  --card-bg: #ffffff;
  --card-border: #efe7d8;
  --green: #a8d96a;
  --green-icon: #3f6b1e;
  --ink: #2a2237;
  --ink-soft: #6a6178;
  --outline-btn-border: #e4dccb;
  --font-display: "Neulis Cursive", -apple-system, BlinkMacSystemFont, "Segoe UI", cursive;
  --font-body: "Circular Std", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

/* Belt-and-suspenders: several elements below set their own `display`
   (flex, for layout), which Ã¢â‚¬â€ same specificity, later in the cascade Ã¢â‚¬â€
   beats the UA stylesheet's default `[hidden]{display:none}`. Applies
   once, here, instead of adding a `[selector][hidden]` override next to
   every such rule. */
[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--purple-bg);
  overflow: hidden;
}

button {
  font-family: inherit;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.screen {
  position: relative;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 16px;
}

.camera-screen {
  background: var(--purple-bg);
}

.result-screen {
  background: var(--cream-bg);
}

/* 3-column grid (empty / card / panel) so the camera card sits at the true
   horizontal center of the screen Ã¢â‚¬â€ the two 1fr tracks balance around it no
   matter how wide the filter/result-actions panel next to it is. A plain
   flex row centered as one unit would instead center the (card + panel)
   pair, pulling the card itself off-center. */
.camera-stage {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: 22px;
  width: 100%;
}

/* --- Page header: back link (closes this tab, opened via target=_blank from
   the main site) + headline, pinned top-left over the screen --- */

.page-header {
  position: absolute;
  top: 32px;
  left: 32px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 18px;
  max-width: 320px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  font-family: inherit;
  font-weight: 700;
  font-size: 12px;
  color: inherit;
  cursor: pointer;
}

.back-link svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.page-headline {
  margin: 0;
  font-family: var(--font-display);
  font-size: 6vh;
  line-height: 1.12;
  font-weight: 700;
}

.camera-screen .back-link,
.camera-screen .page-headline {
  color: #fff;
}

.result-screen .back-link{
  color: var(--ink);
  font-size: 14px;
  font-weight: 400;
}
.result-screen .page-headline {
  color: var(--ink);
  font-size: 23px;
  width: 70%;
  margin-top: 3%;
}

/* --- Camera card --- */

.camera-card {
  position: relative;
  grid-column: 2;
  height: min(82dvh, 900px, 92vw * 1.5);
  width: auto;
  aspect-ratio: 4 / 6;
  background: var(--card-bg);
  border-radius: 25px;
  padding: 10px;
  box-shadow: 0 6px 0px #E1D4CA;
  overflow: hidden;
}

.camera-card video {
  display: none;
}

.camera-card canvas,
.result-card img {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 18px;
  object-fit: cover;
  background: #111;
}

.result-card {
  padding: 14px;
}

/* --- Capture button --- */

.capture-btn {
  position: absolute;
  left: calc(50% - 28px);
  bottom: 30px;
  width: 56px;
  height: 48px;
  border-radius: 14px;
  border: 3px solid #5F8025;
  background: var(--green);
  color: var(--green-icon);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 0px #5F8025;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.capture-btn svg {
  width: 26px;
  height: 26px;
}

.capture-btn:hover {
  transform: scale(1.05);
}

.capture-btn:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

/* --- Countdown / flash / caption overlays --- */

.countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 96px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  border-radius: 18px;
}

.countdown.is-visible {
  opacity: 1;
}

.capture-flash {
  position: absolute;
  inset: 14px;
  background: #fff;
  border-radius: 18px;
  opacity: 0;
  pointer-events: none;
}

.capture-flash.is-flashing {
  opacity: 1;
  transition: opacity 150ms ease-out;
}

/* --- Camera error fallback (permission denied / no device / in use) --- */

.camera-error {
  position: absolute;
  inset: 14px;
  border-radius: 18px;
  background: #221a38;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 28px;
  text-align: center;
  z-index: 2;
}

.camera-error-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.camera-error-icon svg {
  width: 24px;
  height: 24px;
}

.camera-error-message {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.9);
}

.camera-error-retry {
  border: none;
  border-radius: 999px;
  padding: 10px 22px;
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  background: #fff;
  color: var(--purple-primary);
  cursor: pointer;
}

.camera-error-retry:disabled {
  opacity: 0.6;
  cursor: default;
}

.country-caption {
  position: absolute;
  left: 50%;
  top: 20%;
  transform: translateX(-50%);
  padding: 8px 18px;
  border-radius: 999px;
  color: #fff;
  font-weight: 700;
  font-size: 31px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
  text-shadow: 0 3px 13px #00000091;
}

/* "Tap to change country" hint (top: 15%, set on the base rule above) vs
   the per-country-name toast shown on every subsequent tap (top: 50%) Ã¢â‚¬â€
   per-user request (2026-09-04), these two need different vertical
   positions rather than sharing one. */
.country-caption.is-country-name {
  top: 50%;
}

.country-caption.is-visible {
  opacity: 1;
}

/* --- Overlay mode toggles --- */

.filter-panel {
  grid-column: 3;
  justify-self: start;
  display: flex;
  flex-direction: column;
  /* .camera-stage stretches this cell to the camera-card's full height
     (its bottom being the alignment reference); this pins the toggle
     buttons to that bottom edge instead of the top. */
  justify-content: flex-end;
}

.filter-label {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
}

.overlay-toggles {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toggle-btn {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 0 20px 0 5px;
  border-radius: 13px;
  border: none;
  background: var(--card-bg);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 6px 0px #E1D4CA;
}

.toggle-btn:hover:not(:disabled):not(.is-disabled),
.toggle-btn.is-active {
  background: var(--green);
  color: var(--green-icon);
  box-shadow: 0 6px 0px #5F8025;
}

.toggle-btn .toggle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  flex: none;
}

.toggle-btn .toggle-icon img {
  width: 70%;
  height: 70%;
  object-fit: contain;
}

.toggle-label {
  font-weight: 700;
  font-size: 17px;
  text-align: left;
  font-weight: 400;
}

.toggle-btn.is-disabled,
.toggle-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* --- Result screen actions --- */

.result-actions {
  grid-column: 3;
  justify-self: start;
  display: flex;
  flex-direction: column;
  gap: 12px;
  /* .camera-stage stretches this cell to the camera-card's full height
     (its bottom being the alignment reference); this pins the buttons to
     that bottom edge instead of the top. */
  justify-content: flex-end;
  margin-bottom: 1%;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
  box-shadow: 0 6px 0px #E1D4CA;
}
.result-actions .btn svg {
  margin-left: 4px;
}
.btn svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.btn:hover {
  transform: translateY(-1px);
  background: var(--purple-primary);
  color: white;
  box-shadow: 0 6px 0px #441F6C;
  border: 1.5px solid #441F6C;
}

.btn-outline {
  background: var(--card-bg);
  border: 1.5px solid var(--outline-btn-border);
  color: var(--ink);
}

.btn-primary {
  background: var(--purple-primary);
  border: 1.5px solid var(--purple-primary);
  color: #fff;
  box-shadow: 0 6px 0px #441F6C;
}

.btn-primary:hover {
  background: var(--purple-primary-hover);
}

/* --- Responsive: side panel becomes an overlay strip on the card ---
   Two independent triggers, either one switches to the mobile layout:
   narrow viewport width (phones/small tablets Ã¢â‚¬â€ device-type case), OR the
   viewport's own width:height ratio dropping to ~1132:1000 or narrower Ã¢â‚¬â€
   per-user request (2026-09-04) so a desktop browser window resized toward
   square/portrait also gets the mobile layout, not just a literal phone. */

@media (max-width: 640px), (max-aspect-ratio: 1000 / 760) {
  .page-header {
    top: 18px;
    left: 16px;
    gap: 8px;
    max-width: calc(100vw - 32px);
  }

  .page-headline {
    font-size: 22px;
  }

  #camera-header .page-headline {
    display: none;
  }

  /* --- Result screen: one boxed card (its own bg/shadow/radius) holding
     both the photo and the action buttons stacked below it, full width to
     match the photo â€” per client_feedback/3sep/Result Picture - Mobile.jpg
     and per-user request (2026-09-04/2026-09-05: "3 button itu harusnya
     susun ke bawah vertikal, lebar mengikutin canvas result"). Scoped off
     from the camera screen below (which gets a full-bleed layout of its
     own per its own mobile mockup). The outer box-shadow/padding used to
     live on .camera-card itself (the desktop treatment); here it moves up
     to .camera-stage so the buttons can sit inside the same box instead of
     beside/below it as a separate row.

     #result-header switches from the desktop's absolute-overlay (floating
     on top of centered content) to a normal-flow block here â€” otherwise,
     with a tall stacked photo+buttons box vertically centered in the full
     viewport, the header has no reserved space and can overlap the top of
     that box depending on viewport height. */
  .result-screen.screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
    padding: 24px 16px;
  }

  #result-header {
    position: static;
    max-width: none;
    width: 100%;
  }

  .result-screen .camera-stage {
    display: flex;
    flex-direction: column;
    width: min(92vw, 400px);
    margin: 0 auto;
    background: var(--cream-bg);
    border-radius: 14px;
    box-shadow: 0 6px 0px #E1D4CA;
    padding: 18px;
    gap: 12px;
    margin-top: 7%;
    border: 1px solid #E1D4CA;
  }

  .result-screen .camera-card {
    grid-column: auto;
    height: auto;
    width: 100%;
    aspect-ratio: 4 / 6;
    /* Safety cap for short viewports (e.g. iPhone SE) â€” without it, the
       4:6-ratio photo plus 3 stacked buttons below can together exceed the
       viewport height and push the lower buttons off-screen (body has no
       scroll). Past this cap the photo just crops a bit tighter via its
       existing object-fit: cover, no distortion. */
    max-height: min(48dvh, 420px);
    background: transparent;
    border-radius: 18px;
    padding: 0;
    box-shadow: none;
    margin-bottom: 0;
  }

  .result-actions {
    grid-column: auto;
    justify-self: auto;
    flex-direction: column;
    margin-bottom: 0;
    width: 100%;
  }

  /* Icon sits right against its label, both centered as one unit — desktop
     keeps label-left/icon-right with justify-content: space-between (the
     .btn base rule), this mobile-only override is per-user request
     (2026-09-05). */
  .result-actions .btn {
    justify-content: center;
    gap: 0;
  }

  /* --- Camera screen: full-bleed mobile layout per
     client_feedback/3sep/Purikura Photobooth - Mobile.jpg Ã¢â‚¬â€ a floating
     back-link block up top, an edge-to-edge camera fill, and a horizontal
     icon-tab bar pinned to the bottom. Quite different from the desktop
     card + side-panel layout above, so everything here is scoped to
     .camera-screen rather than reusing the shared rules. */
  .camera-screen.screen {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 0;
  }

  #camera-header {
    position: absolute;
    top: 0;
    left: 12px;
    right: 12px;
    z-index: 3;
    max-width: none;
    margin: 0;
    padding: 30px 33px;
    background: var(--cream-bg);
    border-radius: 0 0 18px 18px;
    box-shadow: 0 8px 0px #E1D4CA;
  }

  #camera-header .back-link {
    color: var(--ink);
    font-size: 16px;
    font-weight: 500;
  }

  .camera-screen .camera-stage {
    display: flex;
    flex-direction: column;
    flex: 1;
    width: 100%;
    gap: 0;
  }

  .camera-screen .camera-card {
    grid-column: auto;
    flex: 1;
    height: auto;
    width: 100%;
    aspect-ratio: auto;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    background: transparent;
    margin-bottom: 0;
  }

  .camera-screen .camera-card canvas {
    border-radius: 0;
  }

  .capture-btn {
    background: #5C2D91;
    border-color: #441F6C;
    box-shadow: 0 8px 0px #441F6C;
    color: #fff;
    width: 120px;
    height: 100px;
    left: calc(50% - 60px);
  }

  .capture-btn svg {
    width: 55px;
    height: 55px;
  }

  .filter-panel {
    grid-column: auto;
    justify-self: auto;
    flex: none;
    width: 100%;
    background: var(--cream-bg);
    padding: 10px 8px;
  }

  .filter-label {
    display: none;
  }

  .overlay-toggles {
    flex-direction: row;
    justify-content: space-around;
    gap: 4px;
    margin-bottom: 0;
  }

  .toggle-btn {
    flex: 1 1 0;
    min-width: 0;
    flex-direction: column;
    gap: 7px;
    padding: 6px 16px;
    border-radius: 12px;
    background: transparent;
    box-shadow: none;
  }

  .toggle-btn:hover:not(:disabled):not(.is-disabled),
  .toggle-btn.is-active {
    background: transparent;
    color: var(--ink);
    box-shadow: none;
  }

  .toggle-btn .toggle-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background: #EDF1E0;
    border: 2px solid transparent;
  }

  .toggle-btn.is-active .toggle-icon {
    border-color: var(--purple-primary);
  }

  .toggle-label {
    display: block;
    font-size: 16px;
    line-height: 1.25;
    text-align: center;
    font-weight: 500;
  }
}
