/* Reader pages: newsletter website, signup, confirm, unsubscribe.
   Continues the 析心事務所 brand; reading font is chosen per newsletter. */
@layer reset, base, components;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  img, svg { display: block; max-width: 100%; height: auto; }
  input, button, select, textarea { font: inherit; color: inherit; }
}

@layer base {
  :root {
    --teal-900: #0f3d4d;
    --teal-700: #1a5f7a;
    --teal-200: #a8d0df;
    --ink: #1a1f1e;
    --ink-2: #3d4a47;
    --ink-3: #5f6d69;
    --ground: #f4f6f5;
    --surface: #ffffff;
    --rule: #d5ddd9;
    --ok: #2f6b3f;
    --bad: #a2312b;
    --accent: var(--teal-700);
    --font-read: "Iansui", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
    --measure: 40rem;
    color-scheme: light;
  }
  html { background: var(--ground); }
  body {
    font-family: var(--font-read);
    font-size: 1.0625rem;
    line-height: 1.85;
    color: var(--ink);
    caret-color: var(--accent);
  }
  h1, h2, h3 { color: var(--teal-900); font-weight: 600; line-height: 1.35; text-wrap: balance; }
  h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem); }
  h2 { font-size: 1.35rem; margin-top: 2.2em; }
  h3 { font-size: 1.125rem; margin-top: 1.8em; }
  p, ul, ol, blockquote, figure, pre { margin-top: 1em; }
  a { color: var(--accent); text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent); text-underline-offset: 0.22em; }
  a:hover { text-decoration-color: currentColor; }
  ::selection { background: var(--teal-200); color: var(--teal-900); }
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
  blockquote { padding-left: 1em; border-left: 1px solid var(--rule); color: var(--ink-2); }
  hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5em 0; }
}

@layer components {
  .pub { min-height: 100dvh; display: flex; flex-direction: column; }
  .pub__head {
    width: min(100% - 2.5rem, var(--measure)); margin: 0 auto; padding: 1.5rem 0 0;
    font-weight: 600;
  }
  .pub__head a { color: var(--teal-900); text-decoration: none; }
  .pub__main { width: min(100% - 2.5rem, var(--measure)); margin: 2.5rem auto 4rem; flex: 1; }

  .pub__meta { color: var(--ink-3); font-size: 0.9375rem; }

  .prose img { border-radius: 4px; margin-block: 1.5em; }
  .prose figure figcaption { color: var(--ink-3); font-size: 0.875rem; text-align: center; }
  .prose pre { background: #0f2730; color: #e6f2f6; padding: 1rem; border-radius: 6px; overflow-x: auto; font-size: 0.875rem; }

  /* Signup form */
  .signup { margin-top: 2rem; padding: 1.5rem; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; }
  .signup h2 { margin-top: 0; font-size: 1.25rem; }
  .signup p { margin-top: 0.4rem; color: var(--ink-2); }
  .signup form { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }
  .signup input[type="email"], .signup input[type="text"] {
    flex: 1 1 14rem; min-width: 0; padding: 0.65rem 0.9rem; border: 1px solid var(--rule); border-radius: 6px; background: #fff;
    font-family: "Inter", var(--font-read);
  }
  .signup input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
  .btn-read {
    padding: 0.65rem 1.2rem; border: 0; border-radius: 6px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer;
  }
  .btn-read:hover { background: var(--teal-900); }
  .btn-read[aria-busy="true"] { opacity: 0.7; cursor: progress; }
  .signup .field-stack { display: grid; gap: 0.4rem; margin-top: 1rem; }
  .signup .field-stack label { font-size: 0.9375rem; color: var(--ink-2); }
  .signup .field-stack input { padding: 0.65rem 0.9rem; border: 1px solid var(--rule); border-radius: 6px; background: #fff; font-family: "Inter", var(--font-read); }
  .signup .lists { border: 0; padding: 0; margin-top: 1.2rem; display: grid; gap: 0.4rem; }
  .signup .lists legend { font-weight: 600; color: var(--teal-900); margin-bottom: 0.4rem; }
  .check-read { display: flex; gap: 0.5rem; align-items: center; }
  .check-read input { accent-color: var(--accent); }
  /* Honeypot field: off-screen for people, still in the form for bots. */
  .hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
  .visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
  /* Embedded frame: no page chrome, transparent so it sits in the host page. */
  .embed { background: transparent; margin: 0; }
  .signup--embed { margin: 0; }
  .notice { margin-top: 1rem; padding: 0.9rem 1rem; border-radius: 6px; background: #e5f1e8; color: var(--ok); }
  .notice--bad { background: #f9e6e4; color: var(--bad); }

  /* Issue list on the archive home */
  .issues { list-style: none; padding: 0; margin-top: 2rem; }
  .issues li { padding: 1rem 0; border-top: 1px solid var(--rule); }
  .issues li:last-child { border-bottom: 1px solid var(--rule); }
  .issues a { text-decoration: none; color: var(--teal-900); font-weight: 600; font-size: 1.125rem; }
  .issues a:hover { color: var(--accent); }
  .issues p { margin-top: 0.25rem; color: var(--ink-3); font-size: 0.9375rem; }
  .issues p.topics { margin-top: 0.5rem; }

  /* Site header links (A8-2) */
  .site-nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.2rem; margin-bottom: 1.6rem; font-size: 0.9375rem; }
  .site-nav a { color: var(--ink-2); text-decoration: none; }
  .site-nav a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
  .site-nav a[aria-current="page"] { color: var(--teal-900); font-weight: 600; }

  /* Topic chips and the home's topic filter row (A8-1) */
  .topics { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0; padding: 0; }
  .topics a { font-size: 0.8125rem; line-height: 1; color: var(--teal-700); background: var(--surface);
    border: 1px solid var(--rule); border-radius: 999px; padding: 0.4rem 0.7rem; text-decoration: none; }
  .topics a:hover { border-color: var(--accent); color: var(--accent); }
  .topics a[aria-current="page"] { background: var(--teal-900); border-color: var(--teal-900); color: #fff; }
  .topics--filter { margin: 0 0 0.5rem; }
  .magnet { margin-top: 1.5rem; padding: 1rem 1.2rem; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; }
  .magnet a { font-weight: 600; }

  /* Unsubscribe page */
  .unsub { margin-top: 2rem; padding: 1.5rem; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; max-width: 34rem; }
  .unsub h1 { font-size: 1.375rem; line-height: 1.3; }
  .unsub p { margin-top: 0.6rem; color: var(--ink-2); }
  .unsub form { margin-top: 1.25rem; }
  .btn-read--danger { background: var(--bad); }
  .btn-read--danger:hover { background: #8c2f28; }

  .pub__foot { width: min(100% - 2.5rem, var(--measure)); margin: 0 auto 2rem; color: var(--ink-3); font-size: 0.875rem; }

  /* Newsletter website */
  .site-intro h1 { font-size: clamp(1.8rem, 1.3rem + 2vw, 2.6rem); }
  .site-intro__desc { color: var(--ink-2); font-size: 1.125rem; }
  .site-empty { margin-top: 2rem; }
  .site-foot { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--rule); color: var(--ink-3); font-size: 0.875rem; }
  .issue header { margin-bottom: 2rem; }
  .issue h1 { margin-bottom: 0.4rem; }
  .issue-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
  .issue-nav a { display: grid; gap: 0.2rem; text-decoration: none; color: var(--teal-900); }
  .issue-nav__next { text-align: right; }
  .author { display: grid; gap: 0.6rem; justify-items: start; }
  .author__img { border-radius: 50%; width: 96px; height: 96px; object-fit: cover; }
}
