/* 3D buttons (S5a, owner-approved mock-up s5/buttons.html).
   One raised look for every button in the app and landing page: a soft top highlight,
   a solid "edge" underneath, and a press that sinks the button into its edge.
   Colours come from the brand tokens; the edge tokens below are the only new values.
   Screen only: printed books never show buttons. Reduced motion keeps the look, drops the movement. */
:root {
  --b3-primary-edge: #4E2C33;
  --b3-sec-bg: #FFFAF7;  --b3-sec-edge: #D9C2B6;
  --b3-soft-bg: #F4E2DD; --b3-soft-edge: #DDB9B0;
  --b3-danger-edge: #6E1426;
  --b3-shadow: rgb(60 25 32 / .42);
  --b3-gloss: rgb(255 255 255 / .3);
  --b3-nav-on: linear-gradient(180deg, #F6E6E2, #E8C9C2); --b3-nav-edge: #CFA79E;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --b3-primary-edge: #B9928A;
    --b3-sec-bg: #2A2023;  --b3-sec-edge: #120C0E;
    --b3-soft-bg: #4D2F35; --b3-soft-edge: #2A1A1E;
    --b3-danger-edge: #B5707B;
    --b3-shadow: rgb(0 0 0 / .55);
    --b3-gloss: rgb(255 255 255 / .16);
    --b3-nav-on: linear-gradient(180deg, #5E3A41, #4D2F35); --b3-nav-edge: #2A1A1E;
  }
}
:root[data-theme="dark"] {
  --b3-primary-edge: #B9928A;
  --b3-sec-bg: #2A2023;  --b3-sec-edge: #120C0E;
  --b3-soft-bg: #4D2F35; --b3-soft-edge: #2A1A1E;
  --b3-danger-edge: #B5707B;
  --b3-shadow: rgb(0 0 0 / .55);
  --b3-gloss: rgb(255 255 255 / .16);
  --b3-nav-on: linear-gradient(180deg, #5E3A41, #4D2F35); --b3-nav-edge: #2A1A1E;
}

@media screen {
  /* ---- the shared raised shape ---- */
  .btn, .chip, .prompts button, .book-toggle, .lv-pill, .lv-round {
    --b3-bg: var(--b3-sec-bg); --b3-edge: var(--b3-sec-edge);
    position: relative; isolation: isolate;
    background: linear-gradient(180deg, color-mix(in srgb, var(--b3-bg) 84%, #fff) 0%, var(--b3-bg) 55%, color-mix(in srgb, var(--b3-bg) 90%, #000) 100%);
    box-shadow: 0 4px 0 var(--b3-edge), 0 9px 16px -7px var(--b3-shadow), inset 0 1px 0 var(--b3-gloss);
    transform: translateY(-2px);
    transition: transform .12s var(--ease), box-shadow .12s var(--ease), filter .15s var(--ease), color .15s var(--ease);
    -webkit-tap-highlight-color: transparent;
  }
  /* glossy top highlight */
  .btn::after, .lv-round::after, .lv-pill::after {
    content: ""; position: absolute; z-index: -1; inset: 3px 12% auto; height: 42%;
    border-radius: var(--r-pill); background: linear-gradient(180deg, var(--b3-gloss), transparent); pointer-events: none;
  }
  .btn:hover, .chip:hover, .prompts button:hover, .book-toggle:hover, .lv-pill:hover, .lv-round:hover { filter: brightness(1.04); }

  /* pressed: sinks into its edge */
  .btn:active, .chip:active, .prompts button:active, .book-toggle:active, .lv-pill:active, .lv-round:active {
    transform: translateY(2px);
    box-shadow: 0 0 0 var(--b3-edge), 0 2px 6px -4px var(--b3-shadow), inset 0 2px 4px rgb(0 0 0 / .16);
  }
  /* state "on": stays pressed in */
  .chip[aria-pressed="true"], .chip.is-on, .book-toggle[aria-pressed="true"], .vprompts .prompts button.is-on {
    --b3-bg: var(--b3-soft-bg); --b3-edge: var(--b3-soft-edge);
    transform: translateY(1px);
    box-shadow: 0 1px 0 var(--b3-edge), inset 0 2px 4px rgb(0 0 0 / .14);
  }

  /* ---- variants ---- */
  .btn-primary { --b3-bg: var(--primary); --b3-edge: var(--b3-primary-edge); border-color: transparent; }
  .btn-primary:hover { background: linear-gradient(180deg, color-mix(in srgb, var(--b3-bg) 84%, #fff) 0%, var(--b3-bg) 55%, color-mix(in srgb, var(--b3-bg) 90%, #000) 100%); }
  .btn-secondary { --b3-bg: var(--b3-sec-bg); --b3-edge: var(--b3-sec-edge); border-color: var(--rose); color: var(--primary); }
  .btn-secondary:hover { background: linear-gradient(180deg, color-mix(in srgb, var(--b3-bg) 84%, #fff) 0%, var(--b3-bg) 55%, color-mix(in srgb, var(--b3-bg) 90%, #000) 100%); border-color: var(--gold); }
  .btn-ghost, .btn-quiet-danger { --b3-bg: var(--b3-soft-bg); --b3-edge: var(--b3-soft-edge); padding: 0 var(--s4); }
  .btn-ghost { color: var(--primary); }
  .btn-ghost:hover, .btn-quiet-danger:hover { background: linear-gradient(180deg, color-mix(in srgb, var(--b3-bg) 84%, #fff) 0%, var(--b3-bg) 55%, color-mix(in srgb, var(--b3-bg) 90%, #000) 100%); }
  .btn-danger { --b3-bg: var(--danger); --b3-edge: var(--b3-danger-edge); }
  .btn-sm { box-shadow: 0 3px 0 var(--b3-edge), 0 7px 12px -7px var(--b3-shadow), inset 0 1px 0 var(--b3-gloss); }
  .chip, .prompts button, .book-toggle { box-shadow: 0 3px 0 var(--b3-edge), 0 6px 10px -7px var(--b3-shadow), inset 0 1px 0 var(--b3-gloss); }
  .prompts button { border-style: solid; border-color: var(--line); color: var(--primary); }
  .guide-starter { border-style: dashed; border-color: var(--gold); }
  .lv-pill { --b3-bg: var(--b3-soft-bg); --b3-edge: var(--b3-soft-edge); }

  /* disabled: flat and quiet, no movement */
  .btn[disabled], .btn[aria-disabled="true"], .chip[disabled] {
    transform: none; box-shadow: none; filter: saturate(.6);
  }
  .btn[disabled]::after, .btn[aria-disabled="true"]::after { display: none; }

  /* focus ring, clear on both themes */
  .btn:focus-visible, .chip:focus-visible, .prompts button:focus-visible, .book-toggle:focus-visible, .lv-pill:focus-visible, .lv-round:focus-visible {
    outline: 3px solid var(--gold); outline-offset: 4px;
  }

  /* segmented control: the chosen option is a small raised button */
  .seg button[aria-pressed="true"] {
    background: linear-gradient(180deg, var(--card), color-mix(in srgb, var(--card) 92%, #000));
    box-shadow: 0 2px 0 var(--b3-sec-edge), 0 5px 10px -6px var(--b3-shadow), inset 0 1px 0 var(--b3-gloss);
  }

  /* navigation: the current page looks pressed-in on a raised pad */
  .nav-link[aria-current="page"] { background: var(--b3-nav-on); box-shadow: 0 3px 0 var(--b3-nav-edge), inset 0 1px 0 var(--b3-gloss); }
}
@media screen and (max-width: 899px) {
  .bottom-nav [aria-current="page"] .icon { background: var(--b3-nav-on); box-shadow: 0 3px 0 var(--b3-nav-edge), inset 0 1px 0 var(--b3-gloss); }
}
@media (prefers-reduced-motion: reduce) {
  .btn, .chip, .prompts button, .book-toggle, .lv-pill, .lv-round { transition: none; }
  .btn:active, .chip:active, .prompts button:active, .book-toggle:active, .lv-pill:active, .lv-round:active { transform: translateY(-2px); }
}

/* ---------- S13: bigger, glowing buttons (owner-approved mock-up s12, glow a little stronger) ----------
   Every button keeps the raised 3D shape and gets a soft light around it. The colour of the
   light says what the button does: rose = main action, gold = download/PDF, lavender = 3D
   albums, sage = save, red = delete. Screen only; reduced motion keeps the light, drops movement. */
:root { --g-rose: 232 120 150; --g-gold: 214 160 90; --g-lav: 160 135 225; --g-sage: 95 185 130; --g-red: 225 70 95; --g-soft: 210 150 150; --g-a: .5; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --g-rose: 255 150 178; --g-gold: 255 200 120; --g-lav: 185 165 255; --g-sage: 130 230 165; --g-red: 255 110 130; --g-soft: 255 160 180; --g-a: .6; } }
:root[data-theme="dark"] { --g-rose: 255 150 178; --g-gold: 255 200 120; --g-lav: 185 165 255; --g-sage: 130 230 165; --g-red: 255 110 130; --g-soft: 255 160 180; --g-a: .6; }

@media screen {
  .btn { min-height: 54px; padding: 0 var(--s5); font-size: var(--fs-base); font-weight: 700; --glow: var(--g-soft); }
  :lang(am) .btn { font-size: var(--fs-base); }
  .btn-sm { min-height: 44px; padding: 0 var(--s4); font-size: var(--fs-sm); }
  :lang(am) .btn-sm { font-size: var(--fs-sm); }
  .btn-icon { width: 54px; }
  .chip, .prompts button { min-height: 44px; font-size: var(--fs-sm); font-weight: 600; }
  .btn-primary { --glow: var(--g-rose); }
  .btn-danger, .btn-quiet-danger { --glow: var(--g-red); }
  .btn[data-pdf], [data-action="export-ai-book"] { --glow: var(--g-gold); }
  .btn-primary[data-pdf] { --b3-bg: #C79A6B; --b3-edge: #8E6A45; color: #2E1F14; }
  .btn[data-open3d], .btn[href^="#album"] { --glow: var(--g-lav); }
  #entry-form button[type="submit"], #moment-form button[type="submit"], [data-save-profile] { --glow: var(--g-sage); }

  .btn, .chip, .prompts button, .lv-pill, .lv-round {
    box-shadow: 0 4px 0 var(--b3-edge), 0 0 0 1.5px rgb(var(--glow, var(--g-soft)) / calc(var(--g-a) + .1)),
      0 0 26px 3px rgb(var(--glow, var(--g-soft)) / var(--g-a)), 0 12px 22px -10px rgb(var(--glow, var(--g-soft)) / .6), inset 0 1px 0 var(--b3-gloss);
  }
  .btn-ghost, .chip, .prompts button { box-shadow: 0 3px 0 var(--b3-edge), 0 0 0 1px rgb(var(--glow, var(--g-soft)) / .35), 0 0 14px 1px rgb(var(--glow, var(--g-soft)) / calc(var(--g-a) - .2)), inset 0 1px 0 var(--b3-gloss); }
  .btn:active, .chip:active, .prompts button:active, .lv-pill:active, .lv-round:active {
    box-shadow: 0 0 0 var(--b3-edge), 0 0 0 1.5px rgb(var(--glow, var(--g-soft)) / .7), 0 0 34px 5px rgb(var(--glow, var(--g-soft)) / calc(var(--g-a) + .1)), inset 0 2px 5px rgb(0 0 0 / .2);
  }
  .btn[disabled], .btn[aria-disabled="true"], .chip[disabled] { box-shadow: none; }
  .bottom-nav [aria-current="page"] .icon, .nav-link[aria-current="page"] { box-shadow: 0 3px 0 var(--b3-nav-edge), 0 0 18px rgb(var(--g-rose) / var(--g-a)), inset 0 1px 0 var(--b3-gloss); }
}

/* ---------- S15: blue light on every button and card (owner request) ----------
   The blue halo replaces the coloured one; the 3D edge and the press stay the same.
   S36 review (owner approved): the same light, turned down — a soft halo instead of a strong glow, so the brand
   colours lead. The focus ring (gold outline above) is separate and unchanged. */
:root { --blue-light: 70 150 255; --blue-a: .28; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --blue-light: 90 170 255; --blue-a: .32; } }
:root[data-theme="dark"] { --blue-light: 90 170 255; --blue-a: .32; }
@media screen {
  .btn, .lv-pill, .lv-round {
    box-shadow: 0 4px 0 var(--b3-edge), 0 0 0 1px rgb(var(--blue-light) / .45), 0 0 14px 1px rgb(var(--blue-light) / var(--blue-a)), inset 0 1px 0 var(--b3-gloss);
  }
  .btn-ghost, .btn-sm, .chip, .prompts button {
    box-shadow: 0 3px 0 var(--b3-edge), 0 0 0 1px rgb(var(--blue-light) / .4), 0 0 10px 0 rgb(var(--blue-light) / calc(var(--blue-a) - .06)), inset 0 1px 0 var(--b3-gloss);
  }
  .btn:active, .chip:active, .prompts button:active, .lv-pill:active, .lv-round:active {
    box-shadow: 0 0 0 var(--b3-edge), 0 0 0 1.5px rgb(var(--blue-light) / .6), 0 0 18px 3px rgb(var(--blue-light) / .4), inset 0 2px 5px rgb(0 0 0 / .2);
  }
  .ft-card { border-color: rgb(var(--blue-light) / .45);
    box-shadow: 0 4px 0 rgb(var(--glow) / .35), 0 0 16px 2px rgb(var(--blue-light) / var(--blue-a)), inset 0 1px 0 rgb(255 255 255 / .5); }
  .ft-card:hover, .ft-card:active { box-shadow: 0 2px 0 rgb(var(--glow) / .35), 0 0 22px 4px rgb(var(--blue-light) / .4); }
  .tool-row { border: 2px solid rgb(var(--blue-light) / .5);
    box-shadow: 0 5px 0 color-mix(in srgb, rgb(var(--glow)) 35%, #1A0C12), 0 0 18px 3px rgb(var(--blue-light) / var(--blue-a)), inset 0 1px 0 rgb(255 255 255 / .25); }
  .tool-row:hover, .tool-row:active { box-shadow: 0 2px 0 color-mix(in srgb, rgb(var(--glow)) 35%, #1A0C12), 0 0 24px 5px rgb(var(--blue-light) / .45); }
  .btn[disabled], .btn[aria-disabled="true"], .chip[disabled] { box-shadow: none; }
}
