/*
  One Way Mailbox — design system
  Concept: a receive-only mail slot. The address is a yellow letterbox plate
  with a dark slot that "flaps" when new mail drops in.

  Colour
    --paper   #EEF0F2  cool page ground
    --white   #FFFFFF  reading surfaces (inbox list, message)
    --ink     #14171C  text, borders, the slot
    --steel   #5B6470  secondary text
    --line    #C9CED4  hairline dividers
    --yellow  #FFCC00  letterbox plate (with ink text) — the one loud colour.
                       Never used as a foreground on white: too faint.
    --red     #B3122B  errors only, always paired with a "!" mark

  Type: IBM Plex Sans for reading, IBM Plex Mono for anything you might type
  or read character-by-character (addresses, timers, counts).
*/

:root {
  --paper: #EEF0F2;
  --white: #FFFFFF;
  --ink: #14171C;
  --steel: #5B6470;
  --line: #C9CED4;
  --yellow: #FFCC00;
  --red: #B3122B;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.55 var(--sans);
}

[v-cloak] { visibility: hidden; }

a { color: inherit; text-underline-offset: 3px; }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

.wrap { width: min(100% - 32px, 760px); margin-inline: auto; }

.mono { font-family: var(--mono); font-weight: 500; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute; left: -9999px; top: 12px; z-index: 20;
  background: var(--ink); color: var(--white);
  padding: 10px 14px; border-radius: 6px;
}
.skip:focus { left: 16px; }

/* ---------- Masthead ---------- */

.masthead {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 17px; text-decoration: none;
}

.brand-mark {
  position: relative; flex: none;
  width: 30px; height: 22px;
  background: var(--yellow);
  border: 2px solid var(--ink); border-radius: 5px;
}
.brand-mark::after {
  content: ""; position: absolute;
  left: 5px; right: 5px; top: 50%; height: 4px; margin-top: -2px;
  background: var(--ink); border-radius: 2px;
}

.masthead-note { margin: 0; color: var(--steel); font-size: 14px; }

/* ---------- Intro ---------- */

.intro { padding: 48px 0 28px; }

.intro h1 {
  margin: 0 0 12px;
  max-width: 22ch;
  font-size: clamp(30px, 5.4vw, 46px);
  text-wrap: balance;
  font-weight: 600; line-height: 1.08; letter-spacing: -0.02em;
}

.intro p { margin: 0; max-width: 52ch; color: var(--steel); font-size: 18px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 16px;
  font: 600 15px/1.2 var(--sans);
  border: 2px solid transparent; border-radius: 8px;
  cursor: pointer; text-decoration: none;
}

.btn-ink { background: var(--ink); color: var(--yellow); }
.btn-ink:hover { background: #000; }

.btn-line { background: var(--white); color: var(--ink); border-color: var(--ink); }
.btn-line:hover { background: var(--paper); }

.btn-plain {
  min-height: 44px; padding: 10px 2px;
  background: none; border: 0; color: var(--ink);
  text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px;
}
.btn-plain:hover { text-decoration-thickness: 2px; }

/* ---------- Letterbox plate ---------- */

#app { min-height: 340px; }

.plate {
  position: relative;
  padding: 0 28px 22px;
  background: var(--yellow); color: var(--ink);
  border: 2px solid var(--ink); border-radius: 14px;
}

.slot {
  width: min(60%, 320px); height: 14px;
  margin: 22px auto 24px;
  background: var(--ink); border-radius: 999px;
  transform-origin: 50% 0;
}
.slot.flap { animation: flap 0.7s cubic-bezier(.3, .7, .3, 1); }

@keyframes flap {
  0%   { transform: scaleY(1); }
  25%  { transform: scaleY(2.4); }
  60%  { transform: scaleY(0.8); }
  100% { transform: scaleY(1); }
}

.address-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 18px; }

.address {
  flex: 1 1 280px; min-width: 0; margin: 0;
  font-family: var(--mono); font-weight: 500;
  font-size: clamp(20px, 4.3vw, 30px); line-height: 1.25;
  overflow-wrap: anywhere;
}
.address .domain { opacity: 0.72; white-space: nowrap; }

.plate-hint { margin: 8px 0 0; font-size: 15px; }
.plate-hint.warn,
.field-error {
  display: flex; align-items: flex-start; gap: 8px; width: fit-content; max-width: 100%;
  padding: 6px 10px;
  background: var(--white); color: var(--red);
  border-radius: 6px;
  font-weight: 600;
}
.plate-hint.warn::before,
.field-error::before {
  content: "!";
  content: "!" / "";
  flex: none; display: grid; place-items: center;
  width: 20px; height: 20px; margin-top: 1px;
  background: var(--red); color: var(--white);
  border-radius: 50%; font-size: 13px; line-height: 1;
}

.plate-actions { display: flex; flex-wrap: wrap; gap: 0 22px; margin-top: 8px; }

.edit { display: flex; flex: 1; flex-wrap: wrap; align-items: center; gap: 10px; }

.edit-field {
  display: flex; align-items: baseline; flex: 1 1 300px; min-width: 0;
  padding: 6px 12px;
  background: var(--white); color: var(--ink);
  border: 2px solid var(--ink); border-radius: 8px;
  font-family: var(--mono); font-weight: 500; font-size: clamp(18px, 3.6vw, 24px);
}
.edit-field:focus-within { outline: 3px solid var(--ink); outline-offset: 2px; }
.edit-field input {
  flex: 1; width: 100%; min-width: 0; padding: 4px 0;
  border: 0; background: none; color: var(--ink); font: inherit;
}
.edit-field input:focus { outline: none; }
.edit-field .domain { opacity: 0.6; white-space: nowrap; }

.field-error { flex-basis: 100%; margin: 0; }

.timer { margin-top: 18px; }

.bar { height: 6px; overflow: hidden; background: rgba(20, 23, 28, 0.3); border-radius: 3px; }
.bar span {
  display: block; height: 100%;
  background: var(--ink);
  transform-origin: left; transition: transform 1s linear;
}

.timer-text {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 4px 16px; margin: 8px 0 0; font-size: 15px;
}

/* ---------- Inbox ---------- */

.inbox { margin-top: 44px; scroll-margin-top: 16px; }

.inbox-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 12px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--ink);
}
.inbox-head h2 { margin: 0; font-size: 22px; }

.count {
  margin-left: 6px; padding: 0 8px;
  vertical-align: 3px;
  background: var(--yellow); color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-family: var(--mono); font-size: 14px; font-weight: 500;
}

.status { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--steel); font-size: 14px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.status-dot.on { background: var(--ink); }

.mail-list,
.empty {
  margin: 0; padding: 0; list-style: none;
  background: var(--white);
  border: 1px solid var(--line); border-top: 0; border-radius: 0 0 10px 10px;
}

.empty { padding: 28px 22px; }
.empty p { margin: 0; max-width: 56ch; }
.empty strong { display: block; margin-bottom: 4px; font-size: 18px; }

.notice {
  margin: 12px 0 0; padding: 12px 16px;
  background: var(--white);
  border: 2px solid var(--red); border-radius: 8px;
  color: var(--red); font-weight: 600;
}

.mail {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "from time" "subject subject";
  gap: 2px 16px; width: 100%;
  padding: 14px 20px;
  background: none; border: 0; border-bottom: 1px solid var(--line);
  color: inherit; font: inherit; text-align: left;
  cursor: pointer;
}
.mail-list li:last-child .mail { border-bottom: 0; border-radius: 0 0 10px 10px; }
.mail:hover { background: #F6F7F8; }
.mail:focus-visible { outline-offset: -3px; }

.mail-from    { grid-area: from; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-subject { grid-area: subject; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--steel); }
.mail-time    { grid-area: time; color: var(--steel); font-family: var(--mono); font-size: 13px; padding-top: 2px; }

.mail.unread { box-shadow: inset 5px 0 0 var(--ink); }
.mail.unread .mail-from { font-weight: 600; }
.mail.unread .mail-subject { color: var(--ink); }

.drop-enter-active { transition: transform 0.45s cubic-bezier(.2, .8, .2, 1), opacity 0.45s; }
.drop-enter-from { transform: translateY(-14px); opacity: 0; }

/* ---------- How it works / FAQ ---------- */

.section { margin-top: 72px; padding-top: 24px; border-top: 1px solid var(--line); }
.section h2 { margin: 0 0 18px; font-size: 22px; }

.steps {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px;
  margin: 0; padding: 0; list-style: none; counter-reset: step;
}
.steps li { counter-increment: step; }
.steps li::before {
  content: counter(step);
  display: grid; place-items: center;
  width: 34px; height: 34px; margin-bottom: 12px;
  border: 2px solid var(--ink); border-radius: 50%;
  font-family: var(--mono); font-weight: 500;
}
.steps h3 { margin: 0 0 4px; font-size: 17px; }
.steps p { margin: 0; color: var(--steel); }

.faq { margin: 0; max-width: 64ch; }
.faq dt { font-weight: 600; font-size: 17px; }
.faq dd { margin: 4px 0 22px; color: var(--steel); }

.footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px;
  margin-top: 64px; padding: 24px 0 40px;
  border-top: 1px solid var(--line);
  color: var(--steel); font-size: 14px;
}
.footer p { margin: 0; }

/* ---------- Message reader (dialog + standalone page) ---------- */

.reader {
  width: min(100%, 760px); max-width: 100%;
  height: 100dvh; max-height: 100dvh;
  margin: 0 0 0 auto; padding: 0;
  background: var(--white); color: var(--ink);
  border: 0; border-left: 2px solid var(--ink);
}
.reader[open] { display: flex; flex-direction: column; animation: slide-in 0.25s ease-out; }
.reader:focus-visible { outline: none; }
.reader::backdrop { background: rgba(20, 23, 28, 0.5); }

@keyframes slide-in { from { transform: translateX(28px); opacity: 0; } }

.reader-head { padding: 12px 24px 16px; background: var(--paper); border-bottom: 2px solid var(--ink); }
.reader-head h1,
.reader-head h2 {
  margin: 6px 0 12px;
  font-size: 22px; line-height: 1.25; font-weight: 600;
  overflow-wrap: anywhere;
}

.meta { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; margin: 0; font-size: 14px; }
.meta dt { color: var(--steel); }
.meta dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.reader-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 12px; }

.seg { display: inline-flex; border: 2px solid var(--ink); border-radius: 8px; overflow: hidden; }
.seg button {
  min-height: 36px; padding: 6px 12px;
  background: var(--white); color: var(--ink);
  border: 0; font: 600 14px var(--sans); cursor: pointer;
}
.seg button + button { border-left: 2px solid var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--yellow); }
.seg button:focus-visible { outline-offset: -5px; outline-color: var(--yellow); }

.image-note { display: flex; flex-wrap: wrap; align-items: center; gap: 0 12px; font-size: 14px; color: var(--steel); }
.image-note .btn-plain { min-height: 32px; padding: 4px 0; font-size: 14px; color: var(--ink); }

.reader-body { position: relative; flex: 1; min-height: 0; }
.reader-frame { display: block; width: 100%; height: 100%; border: 0; background: var(--white); }
.reader-msg { margin: 0; padding: 28px 24px; max-width: 56ch; }
.reader-msg.error { color: var(--red); font-weight: 600; }

/* Standalone message page */
.letter {
  margin: 28px 0 0;
  background: var(--white);
  border: 2px solid var(--ink); border-radius: 12px;
  overflow: hidden;
}
.letter .reader-frame { height: auto; min-height: 70vh; }

/* ---------- Responsive & motion ---------- */

@media (max-width: 640px) {
  .intro { padding: 32px 0 22px; }
  .plate { padding: 0 18px 18px; }
  .slot { margin: 18px auto 20px; }
  .address-row .btn-ink { width: 100%; }
  .masthead-note { display: none; }
  .address { font-size: clamp(18px, 5.4vw, 24px); }
  .steps { grid-template-columns: 1fr; gap: 22px; }
  .reader { border-left: 0; }
  .reader-head { padding: 10px 16px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Verification shortcuts: extends the existing letterbox design only. */
.verification {
  margin-top: 32px; padding: 20px;
  background: var(--white); border: 1px solid var(--line); border-radius: 10px;
}
.verification-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 6px 12px; padding-bottom: 10px; border-bottom: 2px solid var(--ink);
}
.verification-head h2 { margin: 0; font-size: 22px; }
.verification-from { margin: 14px 0; overflow-wrap: anywhere; font-size: 15px; }
.verification-note { margin: 10px 0; color: var(--steel); font-size: 14px; overflow-wrap: anywhere; }
.verification-code-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 20px; margin: 20px 0; }
.verification-code { flex: 1 1 240px; min-width: 0; font-size: clamp(24px, 4.5vw, 32px); line-height: 1.4; overflow-wrap: anywhere; user-select: all; }
.verification-action { margin-top: 16px; }
@media (max-width: 640px) {
  .verification { padding: 18px; }
  .verification-code-row .btn, .verification-action .btn { width: 100%; }
}
