/* ------------------------------------------------------------------
   The Birthday Note — a sheet of newsprint.
   Deliberately single-theme: this page is paper, white on any host.
   ------------------------------------------------------------------ */

:root {
  --paper:     #FFFFFF;
  --ink:       #15120D;
  --ink-soft:  #5B564C;
  --rule:      #CBC5B8;
  --rule-hair: #E2DED4;
  --stamp:     #A4231B;
  --ink-ring:      rgba(21, 18, 13, .22);
  --ink-ring-fade: rgba(21, 18, 13, 0);

  --display: "Bodoni Moda", "Times New Roman", Times, serif;
  --label:   "Archivo Narrow", "Helvetica Neue", Arial, sans-serif;

  --col: 32rem;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--display);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.sheet {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100svh;
  max-width: var(--col);
  margin-inline: auto;
  padding: 1.5rem 1.5rem calc(1.5rem + env(safe-area-inset-bottom));
}

/* ---- shared furniture: top rule + date line ---------------------- */

.masthead { padding-top: .25rem; }

.masthead .rule-heavy { height: 3px; background: var(--ink); }
.masthead .rule-hair  { height: 1px; background: var(--ink); margin-top: 3px; }

.edition {
  margin: .7rem 0 0;
  font-family: var(--label);
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-align: center;
}

/* Both screens live in the same grid cell, so the gate can cross-fade
   into the note instead of the two briefly stacking. */
.screen { grid-row: 2; grid-column: 1; }

/* ================================================================
   SCREEN ONE — the coupon. Clip it out, redeem your code.
   ================================================================ */

.screen--gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 0;
}

.coupon {
  width: 100%;
  padding: 2rem 1.6rem 1.6rem;
  border: 1px dashed var(--ink);
  background: var(--paper);
  text-align: center;
}

.coupon-label {
  display: block;
  font-family: var(--label);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.coupon-input {
  display: block;
  width: 100%;
  margin: 1.1rem 0 0;
  padding: .45rem 0 .55rem;
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  background: none;
  color: var(--ink);
  font-family: var(--label);
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: .3em;
  text-align: center;
  text-transform: uppercase;
  text-indent: .3em; /* offsets the trailing letter-space so it reads centred */
  caret-color: var(--ink);
}

.coupon-input:focus { outline: none; border-bottom-width: 2px; padding-bottom: calc(.55rem - 1px); }
.coupon-input::placeholder { color: var(--rule); letter-spacing: .3em; }

.coupon-go {
  margin-top: 1.4rem;
  padding: .55rem 1.6rem;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--label);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform .18s ease;
}

.coupon-go:hover  { transform: scale(1.03); }
.coupon-go:active { transform: scale(.97); }

.coupon-error {
  min-height: 1.15rem; /* reserved, so nothing shifts when it speaks up */
  margin: .95rem 0 0;
  font-family: var(--label);
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--stamp);
  opacity: 0;
}

.coupon-error.is-shown { opacity: 1; }

.coupon.is-wrong { animation: shake .4s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-7px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(2px); }
}

.screen--gate.is-leaving {
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity .45s ease, transform .45s ease;
  pointer-events: none;
}

/* ================================================================
   SCREEN TWO — the note itself.
   ================================================================ */

.screen--note {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 0;
}

.screen--note.is-live { animation: enter .7s ease both; }

@keyframes enter {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.middle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .25rem;
  padding: 2rem 0;
}

/* the cue: one line and an arrow that points at the box.
   The headphones notice takes over the same slot when play is first pressed,
   so the handover costs no layout shift. */

.cue-slot { display: grid; }
.cue, .phones { grid-area: 1 / 1; }

.cue { display: flex; flex-direction: column; align-items: center; gap: .1rem; }

.cue-text {
  margin: 0;
  font-size: clamp(1.35rem, 5.5vw, 1.85rem);
  font-style: italic;
  font-weight: 400;
  line-height: 1.2;
  text-wrap: balance;
}

.arrow {
  display: block;
  overflow: visible;
  margin-left: 2.75rem;
  transform: rotate(-4deg);
  animation: bob 3.4s ease-in-out 1.2s infinite;
}

.arrow path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: draw .9s ease-out .35s forwards;
}

/* once it is playing the arrow has done its job */
.cue.is-done {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .5s ease, transform .5s ease;
  pointer-events: none;
}

@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes bob  { 0%, 100% { transform: rotate(-4deg) translateY(0); }
                  50%      { transform: rotate(-4deg) translateY(6px); } }

/* headphones, shown once — on the first press of play */

.phones {
  align-self: end;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .55rem;
  text-align: center;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .45s ease .12s, transform .45s ease .12s;
}

.phones.is-shown { opacity: 1; transform: translateY(0); }

.phones-line {
  margin: 0;
  font-size: clamp(1.2rem, 4.8vw, 1.6rem);
  font-style: italic;
  font-weight: 400;
  line-height: 1.2;
}

.phones-mark {
  width: .8em;
  height: .8em;
  margin-right: .42em;
  vertical-align: -.04em;
  fill: currentColor;
}

.phones-mark path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
}

.phones-hint {
  margin: 0;
  font-family: var(--label);
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* the button is waiting for a second press */
.play.is-armed { animation: waiting 2.2s ease-in-out infinite; }

@keyframes waiting {
  0%, 100% { box-shadow: 0 0 0 0 var(--ink-ring); }
  70%      { box-shadow: 0 0 0 13px var(--ink-ring-fade); }
}

/* the notice: double-ruled, the way a display ad is set */

.notice {
  position: relative;
  width: 100%;
  padding: 1.6rem 1.45rem;
  border: 1px solid var(--ink);
  background: var(--paper);
}

.notice::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid var(--rule);
  pointer-events: none;
}

.player {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 1.15rem;
}

.play {
  width: 66px;
  height: 66px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  transition: transform .18s ease;
}

.play:hover  { transform: scale(1.04); }
.play:active { transform: scale(.97); }

.play svg { width: 26px; height: 26px; fill: currentColor; }
.play .glyph-pause { display: none; }
.play.is-playing .glyph-play  { display: none; }
.play.is-playing .glyph-pause { display: block; }

.meter { min-width: 0; }

.scrub { padding: 11px 0; cursor: pointer; }

.line { position: relative; height: 2px; background: var(--rule-hair); }

.fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--ink); }

.fill::after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  width: 8px;
  height: 8px;
  background: var(--ink);
  transform: translate(50%, -50%);
}

.times {
  display: flex;
  justify-content: space-between;
  margin-top: .1rem;
  font-family: var(--label);
  font-size: .72rem;
  letter-spacing: .1em;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

/* shown only while no voice note is attached */
.attach { display: none; text-align: center; }
.notice.is-empty .player { display: none; }
.notice.is-empty .attach { display: block; }

.attach button {
  font-family: var(--label);
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink);
  background: none;
  border: 0;
  border-bottom: 1px solid var(--ink);
  padding: .3rem 0;
  cursor: pointer;
}

.attach p {
  margin: .7rem 0 0;
  font-family: var(--label);
  font-size: .68rem;
  letter-spacing: .04em;
  color: var(--ink-soft);
}

/* the headline that prints when the note ends */

.reveal {
  min-height: 7.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: .85rem;
  text-align: center;
}

.headline {
  margin: 0;
  font-size: clamp(2.6rem, 13vw, 4.4rem);
  font-weight: 900;
  line-height: .93;
  letter-spacing: .08em;
  text-wrap: balance;
  opacity: 0;
  transform: translateY(14px);
}

.stamp-rule { width: 0; height: 2px; background: var(--stamp); }

.reveal.is-revealed .headline {
  opacity: 1;
  transform: translateY(0);
  letter-spacing: -.005em;
  transition: opacity .9s ease,
              transform .9s cubic-bezier(.2,.8,.3,1),
              letter-spacing 1.1s cubic-bezier(.2,.8,.3,1);
}

.reveal.is-revealed .stamp-rule {
  width: 3.5rem;
  transition: width .7s cubic-bezier(.2,.8,.3,1) .5s;
}

/* ---- focus, kept visible everywhere ----------------------------- */

.play:focus-visible,
.scrub:focus-visible,
.coupon-go:focus-visible,
.attach button:focus-visible {
  outline: 2px solid var(--stamp);
  outline-offset: 4px;
}

.coupon-input:focus-visible { outline: 2px solid var(--stamp); outline-offset: 6px; }

/* ---- reduced motion --------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .arrow, .arrow path, .coupon.is-wrong, .screen--note.is-live, .play.is-armed { animation: none; }
  .phones { transform: none; transition: opacity .3s ease; }
  .phones.is-shown { transform: none; }
  .arrow path { stroke-dashoffset: 0; }
  .screen--note.is-live { opacity: 1; }
  .reveal.is-revealed .headline { transform: none; letter-spacing: -.005em; transition: opacity .4s ease; }
  .reveal.is-revealed .stamp-rule { transition: none; }
  .cue.is-done { transform: none; transition: opacity .3s ease; }
  .screen--gate.is-leaving { transform: none; }
  .play:hover, .play:active, .coupon-go:hover, .coupon-go:active { transform: none; }
}
