/* COLOURS & FONTS — start here to make it your own. */
:root {
  color-scheme: light;
  --page: #EDF4FA;
  --paper: #FFF9F1;
  --ink: #172B4D;
  --muted: #596A80;
  --button: #172B4D;
  --button-hover: #263F65;
  --accent: #EDC7B7;
  --line: #D9E3ED;
  --focus: #8F5740;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--page);
  /* A quiet paper-like pattern, made entirely in CSS. */
  background-image: radial-gradient(#172b4d0c 0.7px, transparent 0.7px);
  background-size: 7px 7px;
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 3px solid var(--focus); outline-offset: 5px; }

.page-shell {
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
}

.page-header {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.055em;
}

.tiny-spark { color: var(--focus); font-size: 21px; line-height: 1; }
main { width: min(100%, 500px); }

.note-card {
  --art-height: 200px;
  --copy-height: 176px;
  --content-gap: 24px;
  position: relative;
  padding: 26px 40px 16px;
  border: 1px solid #e4e3e0;
  border-radius: 26px;
  background: var(--paper);
  box-shadow: 0 3px 5px #172b4d0c, 0 18px 55px -24px #172b4d30;
  text-align: center;
}

/* The little folded corner is decoration, not a control. */
.card-corner {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 43px;
  height: 43px;
  border-radius: 0 25px 0 14px;
  background: linear-gradient(225deg, var(--page) 48%, #e6c2b3 49%, #f5e2d6 54%);
  filter: drop-shadow(-1px 2px 1px #172b4d0c);
}

/* Shared rows keep every message and the controls at the same position.
   Rows can still grow for enlarged text, so accessibility never clips copy. */
.note-content { display: grid; grid-template-rows: var(--art-height) minmax(var(--copy-height), auto); gap: var(--content-gap); }
.visual-slot { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; height: var(--art-height); min-height: 0; isolation: isolate; }
.visual-slot[data-kind="portrait"]::before { content: ''; position: absolute; z-index: -1; width: 160px; height: 120px; left: 50%; bottom: 8px; transform: translateX(-50%); background: var(--accent); opacity: 0.24; border-radius: 48% 52% 42% 58%; }
/* All faces, hands and the complete pub background remain in the image. */
.note-illustration { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; max-width: 100%; max-height: 100%; object-fit: contain; object-position: center; }
.visual-slot[data-kind="small"] .note-illustration { width: min(170px, 100%); height: min(140px, 100%); }
/* The square sign-off portrait stays 160–180px wide, including on short phones. */
.note-content.has-signoff { grid-template-rows: max(160px, var(--art-height)) minmax(var(--copy-height), auto); }
.visual-slot[data-kind="signoff"] { height: max(160px, var(--art-height)); }
.visual-slot[data-kind="signoff"] .note-illustration { width: min(180px, 100%); }
.pause-symbol { display: flex; align-items: center; justify-content: center; gap: 7px; width: 48px; height: 48px; border: 1px solid var(--line); border-radius: 50%; background: var(--page); }
.pause-symbol span { display: block; width: 4px; height: 17px; border-radius: 2px; background: var(--muted); }
.note-words { width: 100%; max-width: 380px; margin: 0 auto; align-self: start; }
h1 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 27px; line-height: 1.32; letter-spacing: -0.035em; text-wrap: pretty; }
.has-heading h1 { font-size: 53px; line-height: 1.13; letter-spacing: -0.065em; }
#note-body { max-width: 295px; margin: 15px auto 0; font-size: 16px; line-height: 1.65; color: var(--muted); text-wrap: pretty; }
/* The closing and signature stay in normal flow, so the row can grow on phones. */
.closing-line { margin: 24px 0 0; font-family: var(--serif); font-size: 22px; line-height: 1.4; }
.signature { margin: 32px 0 0; font-family: var(--serif); font-size: 16px; line-height: 1.5; color: var(--muted); text-align: right; }
.note-content.has-signoff + .note-navigation { margin-top: 24px; }

.note-navigation { margin-top: 16px; }
.next-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 17px;
  min-height: 54px;
  width: min(100%, 238px);
  margin: 0 auto;
  padding: 14px 22px;
  border: 1px solid transparent;
  border-radius: 13px;
  background: var(--button);
  color: #fffdf7;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 160ms ease, transform 160ms ease;
}

.next-button svg { flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.next-button:active { transform: translateY(1px); }
.navigation-bottom { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-top: 16px; }
.back-button { justify-self: start; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin-left: -9px; padding: 9px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 12px; cursor: pointer; touch-action: manipulation; }
.back-button:disabled { visibility: hidden; }
.progress-dots { display: flex; align-items: center; gap: 6px; }
.progress-dot { display: block; width: 5px; height: 5px; border-radius: 99px; background: var(--line); }
.progress-dot.is-past { background: var(--accent); }
.progress-dot.is-current { width: 18px; height: 5px; background: var(--ink); }
.page-count { justify-self: end; font-size: 10px; font-variant-numeric: tabular-nums; letter-spacing: 0.1em; color: var(--muted); }
.page-footer { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 20px; }
.footer-line { width: 25px; height: 2px; background: var(--accent); }
.page-footer p { margin: 0; color: var(--muted); font-family: var(--serif); font-size: 14px; font-style: italic; }
.no-script { font-size: 16px; line-height: 1.6; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

@media (hover: hover) {
  .next-button:hover { background: var(--button-hover); }
  .back-button:hover { color: var(--ink); background: var(--page); }
}

@media (max-width: 540px) {
  .page-shell { padding-left: 18px; padding-right: 18px; }
  .page-header { margin-bottom: 20px; font-size: 12px; }
  .note-card { --art-height: 180px; --copy-height: 184px; --content-gap: 22px; padding: 24px 26px 14px; border-radius: 23px; }
  h1 { font-size: 26px; }
  .has-heading h1 { font-size: 49px; }
  #note-body { font-size: 16px; }
  .note-navigation { margin-top: 15px; }
  .navigation-bottom { margin-top: 14px; }
  .page-footer { margin-top: 20px; }
}

@media (max-width: 350px) {
  .page-shell { padding-left: 14px; padding-right: 14px; }
  .note-card { padding-left: 22px; padding-right: 22px; }
  h1 { font-size: 24px; }
  .has-heading h1 { font-size: 43px; }
}

@media (max-height: 720px) and (max-width: 540px) {
  .page-shell { padding-top: max(18px, env(safe-area-inset-top)); padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  .page-header { margin-bottom: 15px; }
  .note-card { --art-height: 170px; --copy-height: 162px; --content-gap: 18px; padding-top: 20px; }
  .visual-slot[data-kind="portrait"]::before { width: 140px; height: 100px; }
  .note-navigation { margin-top: 12px; }
  .navigation-bottom { margin-top: 12px; }
  .page-footer { margin-top: 16px; gap: 10px; }
}

@media (max-height: 620px) and (max-width: 540px) {
  .page-shell { padding-top: max(14px, env(safe-area-inset-top)); padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .page-header { margin-bottom: 12px; }
  .note-card { --art-height: 140px; --copy-height: 150px; --content-gap: 10px; padding-top: 16px; padding-bottom: 10px; }
  .visual-slot[data-kind="portrait"]::before { height: 85px; width: 120px; }
  .visual-slot[data-kind="small"] .note-illustration { width: min(150px, 100%); height: min(120px, 100%); }
  h1 { font-size: 24px; }
  .has-heading h1 { font-size: 43px; }
  #note-body { margin-top: 12px; font-size: 15px; }
  .next-button { min-height: 50px; }
  .note-navigation { margin-top: 10px; }
  .navigation-bottom { margin-top: 8px; }
  .page-footer { margin-top: 12px; gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media (forced-colors: active) {
  .progress-dot { background: GrayText; }
  .progress-dot.is-current { background: Highlight; }
  .note-card { border-color: CanvasText; }
}
