/*
 * The landing page (<body class="landing">). Everything is nested under
 * .landing so none of it reaches the rest of the app.
 *
 * The base rules draw the Vinho look; the [data-theme="ameixa"] block at the
 * end makes Ameixa flatter and straighter. Colours come from theme.css.
 *
 * Layout: a header, a hero carousel (4 slides whose headline arrives word by
 * word next to drawn gift boxes), then steps as hanging gift tags, features as
 * postcards, a privacy letter, FAQ and a closing call to action.
 */
.landing {
  --soft: cubic-bezier(.3, 1.35, .5, 1);

  margin: 0;
  font-size: 17px;
  line-height: 1.6;
  overflow-x: hidden;

  * { box-sizing: border-box; }
  h1, h2, h3 { font-family: var(--serif); font-weight: 500; margin: 0; text-wrap: balance; line-height: 1.02; letter-spacing: -.02em; font-variation-settings: var(--axes); }
  p { margin: 0; }
  a { color: inherit; }
  button { font: inherit; color: inherit; cursor: pointer; }
  :focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 10px; }
  em { font-style: var(--em-style); color: var(--accent); }
  .wrap { max-width: 1160px; margin: 0 auto; padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); }

  /* Header */
  .nav { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); }
  .nav .wrap { display: flex; align-items: center; gap: 30px; padding-block: 16px; }
  .logo { font-family: var(--serif); font-size: 26px; font-weight: 600; text-decoration: none; display: flex; align-items: center; gap: 10px; }
  .links { display: flex; gap: 24px; font-weight: 600; font-size: 15px; }
  .links a { text-decoration: none; color: var(--muted); }
  .links a:hover { color: var(--accent); }
  .nav-r { margin-left: auto; display: flex; gap: 12px; align-items: center; }
  @media (max-width: 880px) { .links { display: none; } }
  /* Phones keep "sign in" in the header; the hero already has the sign-up button */
  @media (max-width: 560px) { .nav-r > .btn:not(.line) { display: none; } }

  /* Buttons */
  .btn { display: inline-flex; align-items: center; gap: 10px; border: 0; border-radius: 999px; padding: 14px 24px; font-weight: 700; font-size: 16px; text-decoration: none;
    background: var(--accent); color: var(--on-accent); transition: transform .35s var(--soft), box-shadow .3s; box-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 60%, var(--ink)); white-space: nowrap; }
  .btn:hover { transform: translateY(-3px); box-shadow: 0 7px 0 color-mix(in srgb, var(--accent) 60%, var(--ink)); }
  .btn:active { transform: translateY(2px); box-shadow: 0 2px 0 color-mix(in srgb, var(--accent) 60%, var(--ink)); }
  .btn.line { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
  .btn.line:hover { box-shadow: inset 0 0 0 2px var(--accent); color: var(--accent); }
  .btn.sm { padding: 9px 18px; font-size: 15px; }

  /* Flash messages (for example after signing out) */
  .flash { margin: 0; padding: 12px max(20px, env(safe-area-inset-left, 0px)); background: var(--paper); border-bottom: 1px solid var(--line); text-align: center; font-weight: 600; }

  /* Hero */
  .hero { position: relative; transition: background-color 1.2s ease; background: var(--tint, var(--bg)); overflow: hidden; }
  .hero[data-slide="0"] { --tint: var(--t0); }
  .hero[data-slide="1"] { --tint: var(--t1); }
  .hero[data-slide="2"] { --tint: var(--t2); }
  .hero[data-slide="3"] { --tint: var(--t3); }
  .stage { display: grid; padding-block: 48px 120px; min-height: 620px; }
  .slide { grid-area: 1 / 1; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 40px; align-items: center; visibility: hidden; }
  .slide.active { visibility: visible; }
  @media (max-width: 880px) { .slide { grid-template-columns: 1fr; gap: 24px; } .stage { min-height: 0; } }
  .hand { font-family: var(--serif); font-style: italic; font-size: 22px; color: var(--accent); display: inline-flex; align-items: center; gap: 10px; }
  .hand svg { width: 40px; height: 14px; stroke: var(--accent); fill: none; stroke-width: 2; stroke-linecap: round; }
  .slide h1 { font-size: clamp(46px, 7.6vw, 98px); margin: 16px 0 22px; }
  .w { display: inline-block; opacity: 0; transform: translateY(.5em) rotate(4deg); }
  .slide.active .w { animation: landing-word .8s var(--soft) forwards; animation-delay: calc(var(--d) * 90ms + 100ms); }
  .slide .lead, .slide .ctas, .slide .fine { opacity: 0; transform: translateY(14px); transition: opacity .3s, transform .3s; }
  .slide.active .lead, .slide.active .ctas, .slide.active .fine { opacity: 1; transform: none; transition: opacity .8s ease .6s, transform .8s var(--soft) .6s; }
  .slide.active .ctas { transition-delay: .75s; }
  .slide.active .fine { transition-delay: .9s; }
  .slide .lead { font-size: 20px; color: var(--muted); max-width: 44ch; }
  .ctas { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }
  .fine { margin-top: 16px; font-size: 15px; color: var(--muted); }

  /* Drawn gift boxes: empty elements painted with CSS, with an SVG bow */
  .scene { position: relative; height: 420px; width: min(100%, 440px); justify-self: center; }
  @media (max-width: 880px) { .scene { height: 300px; } }
  .box { will-change: transform; outline: 1px solid transparent; backface-visibility: hidden; position: absolute; bottom: 0; width: var(--w); height: var(--h); left: var(--x);
    opacity: 0; transform: translateY(-120px) rotate(var(--r0, -10deg)); }
  .slide.active .box { animation: landing-drop 1s var(--soft) forwards; animation-delay: calc(var(--d, 0) * 140ms + 200ms); }
  .box .body { position: absolute; inset: 22% 4% 0; background: var(--c); border-radius: 6px 6px 10px 10px; box-shadow: inset 0 -10px 0 rgba(0, 0, 0, .08); }
  .box .lid { position: absolute; left: 0; right: 0; top: 10%; height: 16%; background: var(--c); border-radius: 6px; filter: brightness(.94); box-shadow: 0 4px 0 rgba(0, 0, 0, .08); }
  .box .rib { position: absolute; left: 50%; top: 10%; bottom: 0; width: 13%; translate: -50% 0; background: var(--k); }
  .box.dots .body { background-image: radial-gradient(circle, color-mix(in srgb, var(--c) 50%, var(--k)) 3px, transparent 4px); background-size: 22px 22px; }
  .box.stripes .body { background-image: repeating-linear-gradient(90deg, transparent 0 5px, color-mix(in srgb, var(--c) 60%, var(--paper)) 6px 13px, transparent 14px 24px); }
  .bow { position: absolute; left: 50%; top: 10%; width: 58%; aspect-ratio: 60 / 34; translate: -50% -74%; color: var(--k); overflow: visible; }
  .bow .shade { fill: rgba(0, 0, 0, .18); }

  /* Each slide's boxes: size, position, colours, order and resting tilt */
  .box-2a { --w: 50%; --h: 62%; --x: 8%; --c: var(--second); --k: var(--ribbon); --d: 0; --r: -2deg; }
  .box-2b { --w: 34%; --h: 44%; --x: 60%; --c: var(--fourth); --k: var(--accent); --d: 1; --r: 5deg; --r0: 16deg; }
  .box-3a { --w: 40%; --h: 48%; --x: 4%; --c: var(--fourth); --k: var(--paper); --d: 0; --r: -4deg; }
  .box-3b { --w: 30%; --h: 66%; --x: 40%; --c: var(--accent); --k: var(--ribbon); --d: 1; --r: 1deg; }
  .box-3c { --w: 28%; --h: 40%; --x: 70%; --c: var(--second); --k: var(--paper); --d: 2; --r: 5deg; --r0: 18deg; }
  .box-4a { --w: 58%; --h: 64%; --x: 20%; --c: var(--accent); --k: var(--ribbon); --d: 0; --r: -1deg; }

  /* Slide 1: the pile of small gifts (gift_pile_controller.js) */
  .pile { position: absolute; inset: 0; }
  .gf { position: absolute; left: 0; top: 0; width: var(--w); height: var(--h); will-change: transform; outline: 1px solid transparent; backface-visibility: hidden; }
  .gf .b { position: absolute; inset: 24% 5% 0; background: var(--c); border-radius: 3px 3px 6px 6px; box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .1); }
  .gf .l { position: absolute; left: 0; right: 0; top: 12%; height: 18%; background: var(--c); filter: brightness(.9); border-radius: 3px; box-shadow: 0 2px 0 rgba(0, 0, 0, .1); }
  .gf .r { position: absolute; left: 50%; width: 14%; margin-left: -7%; top: 12%; bottom: 0; background: var(--k); }
  .gf.dots .b { background-image: radial-gradient(circle, color-mix(in srgb, var(--c) 50%, var(--k)) 2px, transparent 3px); background-size: 12px 12px; }
  .gf.stripes .b { background-image: repeating-linear-gradient(90deg, transparent 0 3px, color-mix(in srgb, var(--c) 60%, var(--paper)) 4px 8px, transparent 9px 14px); }

  /* The little cards next to the boxes */
  .note { position: absolute; z-index: 2; background: var(--paper); border-radius: 14px; padding: 12px 16px; box-shadow: 0 16px 30px -18px rgba(59, 26, 36, .5); font-weight: 700; font-size: 15px;
    opacity: 0; transform: translateY(10px) rotate(-3deg); }
  .slide.active .note { animation: landing-pop .8s var(--soft) forwards; animation-delay: 1.1s; }
  .note small { display: block; font-weight: 600; color: var(--muted); font-size: 12px; }
  .note .big { font-family: var(--serif); font-size: 28px; font-weight: 600; letter-spacing: .04em; }
  .note-1 { left: -4%; top: 8%; }
  .note-2 { right: 0; top: 6%; }
  .note-3 { left: 12%; top: 2%; }
  .note-4 { right: 2%; top: 10%; }

  /* Hero controls: progress bars and previous / pause / next */
  .controls { position: absolute; left: 0; right: 0; bottom: 34px; }
  .controls .wrap { display: flex; align-items: center; gap: 14px; }
  .bars { display: flex; gap: 6px; }
  .bar { width: 46px; height: 6px; border: 0; padding: 0; border-radius: 3px; background: var(--line); position: relative; overflow: hidden; }
  .bar .fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); border-radius: 3px; }
  .bar[aria-current="true"] .fill { animation: landing-fill 6s linear forwards; }
  /* Paused with the button, while the keyboard is inside the hero, or while a mouse rests on the controls */
  .hero.paused .bar .fill, .hero:has(:focus-visible) .bar .fill { animation-play-state: paused; }
  @media (hover: hover) { .controls:hover .bar .fill { animation-play-state: paused; } }
  .round { width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--ink); background: transparent; display: grid; place-items: center; transition: background .2s, color .2s; }
  .round:hover { background: var(--ink); color: var(--paper); }
  .round svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
  .round .solid { fill: currentColor; stroke: none; }
  .round .play { display: none; }
  .hero.paused .round .play { display: block; }
  .hero.paused .round .pause { display: none; }
  .controls .round:first-of-type { margin-left: auto; }
  @media (max-width: 640px) {
    .stage { padding-bottom: 170px; }
    .controls { bottom: 26px; }
    .controls .wrap { flex-wrap: wrap; row-gap: 18px; justify-content: center; }
    .bars { flex: 1 1 100%; justify-content: center; }
    .controls .round:first-of-type { margin-left: 0; }
  }

  /* Sections */
  section.block { padding-block: 110px 0; }
  .title { display: grid; gap: 14px; margin-bottom: 48px; max-width: 760px; }
  .title h2 { font-size: clamp(36px, 5.4vw, 66px); }
  .title p { color: var(--muted); font-size: 19px; }

  /* Steps as hanging gift tags */
  .tags { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; padding-top: 40px; position: relative; }
  .tags::before { content: ""; position: absolute; left: -4%; right: -4%; top: 0; height: 40px; border-top: 2px dashed var(--line); border-radius: 50%; }
  @media (max-width: 820px) { .tags { grid-template-columns: 1fr; padding-top: 10px; } .tags::before { display: none; } }
  .tagcard { position: relative; background: var(--paper); border-radius: 18px 18px 24px 24px; padding: 44px 26px 28px; display: grid; gap: 10px; transform-origin: 50% -30px;
    transition: transform .7s var(--soft); clip-path: polygon(16% 0, 84% 0, 100% 14%, 100% 100%, 0 100%, 0 14%); box-shadow: 0 20px 30px -24px rgba(59, 26, 36, .6); }
  .tagcard:nth-child(1) { rotate: -2deg; }
  .tagcard:nth-child(2) { rotate: 1.5deg; margin-top: 18px; }
  .tagcard:nth-child(3) { rotate: -1deg; }
  .tagcard:hover { transform: rotate(4deg); }
  .tagcard::before { content: ""; position: absolute; top: 14px; left: 50%; width: 14px; height: 14px; border-radius: 50%; translate: -50% 0; background: var(--bg); box-shadow: inset 0 0 0 2px var(--line); }
  .tagcard .step { font-family: var(--serif); font-style: italic; color: var(--accent); font-size: 20px; }
  .tagcard h3 { font-size: 30px; }
  .tagcard p { color: var(--muted); }

  /* Features as postcards */
  .posts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); gap: 22px; }
  .post { background: var(--paper); border-radius: 22px; padding: 26px; display: grid; grid-template-columns: minmax(0, 1fr) 84px; gap: 18px; position: relative; min-width: 0;
    transition: transform .5s var(--soft), box-shadow .3s; box-shadow: 0 1px 0 var(--line); }
  .post:hover { transform: translateY(-6px) rotate(-.6deg); box-shadow: 0 24px 34px -26px rgba(59, 26, 36, .6); }
  .post h3 { font-size: 26px; margin-bottom: 8px; }
  .post p { color: var(--muted); font-size: 16px; }
  .stamp { width: 84px; height: 100px; border-radius: 6px; display: grid; place-items: center; font-family: var(--serif); font-size: 15px; font-weight: 600; text-align: center; color: var(--paper);
    padding: 8px; line-height: 1.15; background: var(--c); outline: 3px dotted var(--paper); outline-offset: -7px; rotate: 4deg; }
  .stamp-accent { --c: var(--accent); }
  .stamp-second { --c: var(--second); }
  .stamp-fifth { --c: var(--fifth); }
  .stamp-sixth { --c: var(--sixth); }
  .post .go { grid-column: 1 / -1; font-weight: 700; color: var(--accent); text-decoration: none; justify-self: start; border-bottom: 2px solid currentColor; }

  /* Privacy as a letter */
  .letter { margin-top: 110px; background: var(--paper); border-radius: 28px; padding: clamp(28px, 6vw, 72px); display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
    gap: clamp(24px, 5vw, 64px); position: relative; box-shadow: 0 30px 50px -40px rgba(59, 26, 36, .7); }
  @media (max-width: 860px) { .letter { grid-template-columns: 1fr; } }
  .letter::after { content: ""; position: absolute; inset: 14px; border-radius: 18px; border: 1.5px dashed var(--line); pointer-events: none; }
  .letter h2 { font-size: clamp(36px, 5vw, 58px); margin-top: 12px; }
  .letter .intro { color: var(--muted); margin-top: 18px; font-size: 18px; }
  .letter .sign { font-family: var(--serif); font-style: italic; font-size: 22px; color: var(--accent); margin-top: 18px; }
  .promises { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; }
  .promises li { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 14px; }
  .promises li::before { content: "✓"; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--second); color: var(--paper); font-weight: 700; }
  .promises b { display: block; font-size: 18px; }
  .promises span { color: var(--muted); }

  /* FAQ */
  .faq { display: grid; gap: 12px; max-width: 860px; }
  .faq details { background: var(--paper); border-radius: 18px; padding: 2px 24px; }
  .faq summary { list-style: none; cursor: pointer; padding: 20px 0; font-family: var(--serif); font-size: 22px; font-weight: 500; display: flex; justify-content: space-between; gap: 16px; align-items: center; }
  .faq summary::-webkit-details-marker { display: none; }
  .faq summary::after { content: "+"; font-family: var(--sans); width: 30px; height: 30px; flex: none; border-radius: 50%; background: var(--bg); display: grid; place-items: center; transition: rotate .4s var(--soft); }
  .faq details[open] summary::after { rotate: 135deg; }
  .faq details p { color: var(--muted); padding-bottom: 22px; max-width: 62ch; }

  /* Closing: a gift that opens over the last button */
  .closing { margin-top: 130px; padding-block: 40px 100px; display: grid; justify-items: center; text-align: center; gap: 22px; }
  .closing h2 { font-size: clamp(42px, 7vw, 86px); max-width: 13ch; }
  .closing p { color: var(--muted); font-size: 19px; }
  .gift { position: relative; width: 150px; height: 130px; margin-bottom: 10px; }
  .gift .body { position: absolute; left: 10px; right: 10px; bottom: 0; height: 84px; background: var(--accent); border-radius: 6px 6px 12px 12px; }
  .gift .rib { position: absolute; left: 50%; bottom: 0; width: 18px; height: 84px; translate: -50% 0; background: var(--ribbon); }
  .gift .lid { position: absolute; left: 0; right: 0; bottom: 80px; height: 26px; background: var(--accent-2); border-radius: 6px; transition: transform .7s var(--soft); transform-origin: 10% 100%; }
  .gift .lid::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 18px; translate: -50% 0; background: var(--ribbon); }
  .gift .lid::after { content: ""; position: absolute; left: 50%; bottom: 100%; width: 60px; height: 30px; translate: -50% 0; border: 7px solid var(--ribbon); border-bottom: 0; border-radius: 30px 30px 0 0; }
  .gift .pop { position: absolute; left: 50%; bottom: 70px; translate: -50% 0; font-family: var(--serif); font-size: 34px; opacity: 0; transition: transform .7s var(--soft), opacity .3s; }
  .closing:has(.btn:hover) .gift .lid, .gift:hover .lid { transform: translateY(-28px) rotate(-16deg); }
  .closing:has(.btn:hover) .gift .pop, .gift:hover .pop { opacity: 1; transform: translateY(-40px); }

  /* Footer */
  .site-footer { border-top: 1px solid var(--line); padding-block: 30px calc(30px + env(safe-area-inset-bottom, 0px)); color: var(--muted); font-size: 14px; }
  .site-footer .wrap { display: flex; flex-wrap: wrap; gap: 14px 24px; }
  .site-footer nav { margin-left: auto; display: flex; gap: 20px; }
  .site-footer a { text-decoration: none; font-weight: 600; }
  .site-footer a:hover { color: var(--accent); }

  /* Sections rise in as they scroll into view (browsers that support it) */
  @supports (animation-timeline: view()) {
    .reveal { animation: landing-rise linear both; animation-timeline: view(); animation-range: entry 0% entry 55%; }
  }

  /* Ameixa: flat buttons, bordered cards, straight edges, label pills */
  [data-theme="ameixa"] & {
    h1, h2, h3 { font-weight: 600; letter-spacing: -.025em; }
    .hand { font-family: var(--sans); font-style: normal; font-size: 13px; font-weight: 600; color: var(--muted); padding: 2px 10px; border: 1px solid var(--line); border-radius: 2em; background: var(--paper); }
    .hand svg { display: none; }
    .btn { border-radius: 6px; box-shadow: none; }
    .btn:hover { background: var(--accent-2); box-shadow: none; transform: none; }
    .btn.line { background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
    .btn.line:hover { background: var(--bg); box-shadow: inset 0 0 0 1px var(--muted); }
    .tagcard, .post, .letter, .faq details, .note { box-shadow: none; border: 1px solid var(--line); }
    .tagcard { clip-path: none; border-radius: 12px; rotate: 0deg; margin-top: 0; }
    .tagcard::before, .tags::before, .letter::after { display: none; }
    .tagcard .step, .letter .sign { font-style: normal; font-size: 14px; font-weight: 600; }
    .post, .letter, .faq details { border-radius: 12px; }
    .post:hover { transform: translateY(-3px); }
    .stamp { rotate: 0deg; border-radius: 8px; }
    .note { rotate: 0deg; border-radius: 8px; }
  }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition-duration: .01s !important; transition-delay: 0s !important; }
    .w, .box, .note { opacity: 1 !important; transform: none !important; }
  }
}

@keyframes landing-word { to { opacity: 1; transform: none; } }
@keyframes landing-drop {
  0% { opacity: 0; transform: translateY(-160px) rotate(var(--r0, -10deg)); }
  30% { opacity: 1; }
  100% { opacity: 1; transform: translateY(0) rotate(var(--r, 0deg)); }
}
@keyframes landing-pop { to { opacity: 1; transform: rotate(-3deg); } }
@keyframes landing-fill { to { width: 100%; } }
@keyframes landing-rise { from { opacity: 0; transform: translateY(40px) rotate(-1deg); } }

html:has(body.landing) { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html:has(body.landing) { scroll-behavior: auto; } }
