/* いまバズ
   Visual idea: the TV "telop" and the manga burst — the vernacular of buzz in
   Japan. The burst logo and the yellow top-3 rank numbers are the only loud
   parts; everything else stays quiet so the X embeds carry the page. */

:root {
  --bg: #f1f3f9;
  --surface: #ffffff;
  --ink: #1a1d4e;
  --ink-2: #4b4f7a;
  --ink-3: #7d81a8;
  --line: #dadeeb;
  --yellow: #ffd400;
  --yellow-soft: #fff4b8;
  --red: #e8304f;
  --footer-bg: #1a1d4e;
  --footer-ink: #c9cbee;
  --comment-bg: #f6f7fc;
  --focus: #1a1d4e;

  --display: "Dela Gothic One", "Zen Kaku Gothic New", "Hiragino Sans", sans-serif;
  --text: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", system-ui, sans-serif;

  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f2b;
    --surface: #161941;
    --ink: #eef0ff;
    --ink-2: #b8bbe0;
    --ink-3: #8084b0;
    --line: #2a2e5c;
    --yellow-soft: #3a3510;
    --red: #ff6680;
    --footer-bg: #080a20;
    --footer-ink: #a9acd6;
    --comment-bg: #1c1f4b;
    --focus: #ffd400;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0d0f2b;
  --surface: #161941;
  --ink: #eef0ff;
  --ink-2: #b8bbe0;
  --ink-3: #8084b0;
  --line: #2a2e5c;
  --yellow-soft: #3a3510;
  --red: #ff6680;
  --footer-bg: #080a20;
  --footer-ink: #a9acd6;
  --comment-bg: #1c1f4b;
  --focus: #ffd400;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--text);
  font-size: 15px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

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

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}

.skip {
  position: absolute;
  left: 8px;
  top: -48px;
  z-index: 100;
  padding: 8px 14px;
  background: var(--yellow);
  color: #1a1d4e;
  font-weight: 700;
  border-radius: 8px;
}

.skip:focus { top: 8px; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- logo ---------- */
.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.mark {
  flex: none;
  width: 52px;
  height: 52px;
  overflow: visible;
}

.mark polygon {
  fill: var(--yellow);
  stroke: #1a1d4e;
  stroke-width: 4;
  stroke-linejoin: miter;
}

.mark text {
  fill: #1a1d4e;
  font-family: var(--display);
  font-size: 46px;
  text-anchor: middle;
  dominant-baseline: central;
}

.logo-word {
  font-family: var(--display);
  font-size: 30px;
  line-height: 1;
  letter-spacing: .01em;
}

/* the burst turns a little when the logo is pointed at */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .logo .mark { transition: transform .4s cubic-bezier(.3, 1.6, .5, 1); }
  .logo:hover .mark { transform: rotate(22.5deg) scale(1.06); }
}

/* ---------- masthead ---------- */
.masthead {
  padding: 22px 0 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.beta {
  margin-left: auto;
  padding: 1px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-3);
  font-size: 11px;
  white-space: nowrap;
}

.tagline {
  margin: 10px 0 0;
  color: var(--ink-2);
  font-size: 13px;
}

/* genre tabs: the active one is a telop strip */
.tabs {
  display: flex;
  gap: 4px;
  margin: 14px -16px 0;
  padding: 0 16px 12px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: none;
  padding: 6px 16px 7px;
  border: 2px solid transparent;
  border-radius: 10px;
  color: var(--ink-2);
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
}

.tab:hover { color: var(--ink); background: var(--bg); }

.tab[aria-current="page"] {
  background: var(--yellow);
  border-color: #1a1d4e;
  color: #1a1d4e;
  box-shadow: 3px 3px 0 #1a1d4e;
}

/* ---------- edition heading ---------- */
.edition-head { margin: 22px 0 0; }

.updated-at {
  margin: 0;
  color: var(--ink-3);
  font-size: 13px;
  font-feature-settings: "tnum";
}

.ed-summary {
  max-width: 40em;
  margin: 6px 0 0;
  font-size: 16px;
  line-height: 1.9;
}

.genre-notice {
  max-width: 40em;
  margin: 12px 0 0;
  padding: 10px 14px;
  border-left: 4px solid var(--yellow);
  background: var(--surface);
  border-radius: 0 8px 8px 0;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.7;
}

/* ---------- controls ---------- */
.controls {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: flex-end;
  margin: 18px -16px 0;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.sort {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-3);
  font-size: 12px;
}

.sort select {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

/* ---------- ranking ---------- */
.ranking {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Entries are rows, not boxed cards: the embed already is a card. */
.card {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 0 8px;
  padding: 26px 0 24px;
  border-top: 1px solid var(--line);
}

.card:first-child { border-top: 0; }

/* keep the rank clear of the sticky sort bar when jumping to a post */
.card { scroll-margin-top: 64px; }

.card[hidden] { display: none; }

.rank {
  position: relative;
  align-self: start;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 4px;
  color: var(--ink);
}

.rank-num {
  font-family: var(--display);
  font-size: 44px;
  line-height: 1;
  font-feature-settings: "tnum";
  letter-spacing: -.03em;
}

.rank-unit {
  margin-top: 4px;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 700;
}

/* top 3: telop numbers, yellow with a thick indigo edge */
.card.top .rank-num {
  color: var(--yellow);
  -webkit-text-stroke: 7px #1a1d4e;
  paint-order: stroke fill;
  font-size: 58px;
  text-shadow: 4px 4px 0 #1a1d4e;
}

.card.top1 .rank-num { font-size: 72px; }

/* the burst sits behind number 1 only */
.card.top1 .rank::before {
  content: "";
  position: absolute;
  top: -14px;
  left: 50%;
  width: 104px;
  height: 104px;
  margin-left: -52px;
  z-index: -1;
  background: var(--yellow-soft);
  clip-path: polygon(50% 0%, 57.5% 12%, 69% 4%, 72% 18%, 85% 15%, 83% 28%, 96% 31%, 89% 42%, 100% 50%, 89% 58%, 96% 69%, 83% 72%, 85% 85%, 72% 82%, 69% 96%, 57.5% 88%, 50% 100%, 42.5% 88%, 31% 96%, 28% 82%, 15% 85%, 17% 72%, 4% 69%, 11% 58%, 0% 50%, 11% 42%, 4% 31%, 17% 28%, 15% 15%, 28% 18%, 31% 4%, 42.5% 12%);
}

.card.top1 .rank { isolation: isolate; }

.body { min-width: 0; }

/* ---------- X embed ---------- */
.embed { position: relative; }

.fallback {
  padding: 16px 18px;
  min-height: 120px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.author {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  min-width: 0;
}

.author .name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.author .handle,
.author time {
  color: var(--ink-3);
  font-size: 13px;
  white-space: nowrap;
}

.embed-status {
  margin: 8px 0 0;
  color: var(--ink-3);
  font-size: 13px;
}

.embed-status:empty { display: none; }

.card[data-embed="loading"] .embed-status::before,
.reply[data-embed="loading"] .embed-status::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border: 2px solid var(--line);
  border-top-color: var(--ink);
  border-radius: 50%;
  vertical-align: -1px;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.card[data-embed="done"] .fallback { display: none; }

.embed-slot .twitter-tweet,
.reply-slot .twitter-tweet,
.sheet-embed .twitter-tweet { margin: 0 auto !important; }

/* a transparent button over the embed opens the detail panel */
.embed-cover {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.embed-cover:focus-visible { border-radius: 12px; }

/* ---------- metrics row ---------- */
.footer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--ink-2);
  font-size: 13px;
  font-feature-settings: "tnum";
}

.metrics li {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.metrics svg,
.reply-likes svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--ink-3);
}

.metrics li.hot { color: var(--red); font-weight: 700; }
.metrics li.hot svg { color: var(--red); }

.more-btn {
  padding: 5px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.more-btn:hover { border-color: var(--ink); color: var(--ink); }

/* ---------- comments (collapsed by default) ---------- */
.comments {
  margin-top: 12px;
  border-radius: 12px;
  background: var(--comment-bg);
}

.comments > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: 12px;
  list-style: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  -webkit-tap-highlight-color: transparent;
}

.comments > summary::-webkit-details-marker { display: none; }

.comments-count {
  color: var(--ink-3);
  font-weight: 500;
}

.comments > summary::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-left: auto;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform .2s;
}

.comments[open] > summary::after { transform: translateY(2px) rotate(-135deg); }

.comments > .replies { padding: 0 12px 12px; }

.comments-none {
  margin: 12px 0 0;
  color: var(--ink-3);
  font-size: 12px;
}

.replies {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.reply { min-width: 0; }

.reply-fallback {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface);
}

.reply-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  font-size: 12px;
}

.reply-head .name {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.reply-head .handle {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-3);
}

.reply-likes {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: auto;
  color: var(--ink-3);
  font-feature-settings: "tnum";
}

.reply-likes svg { width: 12px; height: 12px; stroke-width: 2; }

.reply-fallback .embed-status { margin-top: 4px; font-size: 12px; }

.reply-link {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 700;
}

.reply-link[hidden] { display: none; }

.reply[data-embed="done"] .reply-fallback { display: none; }

/* ---------- below the ranking ---------- */
.score-note {
  margin: 8px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 12px;
}

.edition-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin: 28px 0 56px;
  font-size: 14px;
}

.edition-nav a {
  color: var(--ink-2);
  font-weight: 700;
  text-decoration: none;
}

.edition-nav a:hover { color: var(--ink); text-decoration: underline; }

.edition-nav .all {
  padding: 8px 18px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  color: var(--ink);
}

.edition-nav .all:hover { background: var(--yellow); color: #1a1d4e; border-color: #1a1d4e; text-decoration: none; }

.edition-nav .next { text-align: right; }

/* ---------- detail panel ---------- */
body.sheet-open { overflow: hidden; }

.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet[hidden] { display: none; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(13, 15, 43, .6);
}

.sheet-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(640px, 100%);
  max-height: 92vh;
  max-height: 92dvh;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, .25);
}

.sheet-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 10px 18px;
  border-bottom: 1px solid var(--line);
}

.sheet-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.sheet-close {
  flex: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--bg);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.sheet-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 16px calc(24px + env(safe-area-inset-bottom));
}

.sheet-body .fallback { min-height: 0; }

.sheet-comments { margin-top: 14px; }

.sheet-xlink {
  display: block;
  width: fit-content;
  margin: 18px auto 0;
  padding: 10px 24px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.sheet-note {
  margin: 8px 0 0;
  color: var(--ink-3);
  font-size: 11px;
  text-align: center;
}

@media (min-width: 720px) {
  .sheet { align-items: center; }
  .sheet-panel { border-radius: 18px; max-height: 88vh; }
}

/* ---------- archive ---------- */
.archive {
  display: grid;
  margin: 8px 0 56px;
  padding: 0;
  list-style: none;
}

.archive li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.arch-label {
  min-width: 10em;
  font-weight: 700;
}

.arch-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.arch-links a {
  padding: 3px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.arch-links a:hover { border-color: var(--ink); }

/* ---------- fixed pages (about, privacy, terms) ---------- */
.doc { padding-bottom: 56px; }

.doc-title {
  margin: 36px 0 8px;
  font-family: var(--display);
  font-size: 34px;
  font-weight: 400;
  line-height: 1.3;
}

.doc h2 {
  margin: 40px 0 10px;
  padding-left: 12px;
  border-left: 6px solid var(--yellow);
  font-size: 19px;
  line-height: 1.5;
}

.doc h3 {
  margin: 24px 0 6px;
  font-size: 16px;
}

.doc p,
.doc li { max-width: 40em; }

.doc ul,
.doc ol { padding-left: 1.4em; }

.doc li + li { margin-top: 4px; }

.doc .lead { color: var(--ink-2); }

.doc .updated {
  margin-top: 40px;
  color: var(--ink-3);
  font-size: 13px;
}

.doc dl {
  display: grid;
  grid-template-columns: minmax(6em, max-content) 1fr;
  gap: 10px 20px;
  margin: 12px 0 0;
}

.doc dt { color: var(--ink-3); font-weight: 700; }
.doc dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.table-scroll {
  overflow-x: auto;
  margin: 12px 0 0;
}

.doc table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 14px;
}

.doc th,
.doc td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.doc th {
  color: var(--ink-3);
  font-size: 13px;
  white-space: nowrap;
}

.mail-box {
  margin: 14px 0 0;
  padding: 18px 20px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--surface);
}

.mail-box p { margin: 0; }

.mail-box .addr {
  margin-top: 4px;
  font-size: 18px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.button {
  display: inline-block;
  margin-top: 12px;
  padding: 9px 20px;
  border: 2px solid #1a1d4e;
  border-radius: 10px;
  background: var(--yellow);
  color: #1a1d4e;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 3px 3px 0 #1a1d4e;
}

.button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #1a1d4e; }

.template {
  margin: 12px 0 0;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--comment-bg);
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 14px;
}

/* 404 */
.lost {
  margin: 48px 0 64px;
  text-align: center;
}

.lost .mark { width: 120px; height: 120px; }
.lost .mark text { font-size: 46px; }

/* ---------- footer ---------- */
.site-footer {
  padding: 36px 0 calc(40px + env(safe-area-inset-bottom));
  background: var(--footer-bg);
  color: var(--footer-ink);
  font-size: 12px;
}

.site-footer .logo { color: #ffffff; }
.logo-small .mark { width: 38px; height: 38px; }
.logo-small .logo-word { font-size: 22px; }

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin: 20px 0 18px;
  font-size: 14px;
}

.footer-links a {
  color: #ffffff;
  font-weight: 700;
  text-decoration: none;
}

.footer-links a:hover { text-decoration: underline; }

.site-footer p { margin: 0 0 6px; }

.site-footer :focus-visible { outline-color: var(--yellow); }

/* ---------- small screens ---------- */
@media (max-width: 560px) {
  .mark { width: 44px; height: 44px; }
  .logo-word { font-size: 25px; }

  /* the rank sits above the embed, on one line */
  .card {
    grid-template-columns: minmax(0, 1fr);
    padding: 22px 0 20px;
  }
  .rank {
    flex-direction: row;
    align-items: baseline;
    gap: 4px;
    margin: 0 0 10px 2px;
    padding-top: 0;
  }
  .rank-num { font-size: 38px; }
  .rank-unit { margin-top: 0; }
  .card.top .rank-num { font-size: 46px; -webkit-text-stroke-width: 6px; text-shadow: 3px 3px 0 #1a1d4e; }
  .card.top1 .rank-num { font-size: 54px; }
  .card.top1 .rank::before { top: -22px; left: -18px; margin-left: 0; width: 96px; height: 96px; }
  .edition-nav { grid-template-columns: 1fr 1fr; }
  .edition-nav .all { grid-column: 1 / -1; grid-row: 1; justify-self: center; }
}

@media (prefers-reduced-motion: reduce) {
  .card[data-embed="loading"] .embed-status::before,
  .reply[data-embed="loading"] .embed-status::before { animation: none; }
  .comments > summary::after { transition: none; }
}
