/* Codex Resets
   Visual thesis: sticker-sheet neo-brutalism. Warm cream paper, thick ink
   outlines, hard offset shadows, one loud orange, pastel sticker cards set
   at slight angles, rounded display type (Baloo 2). The humor is deadpan:
   the layout is a shrine to one man's tweets and the copy plays it straight.
   Signature interaction: buttons physically depress (shadow collapses),
   reset cells bounce on hover, the bell wiggles. */

@font-face {
  font-family: "Baloo 2";
  font-style: normal;
  font-weight: 700;
  font-display: optional;
  src: url("/assets/baloo-bold?v=4") format("woff2");
}

@font-face {
  font-family: "Baloo 2";
  font-style: normal;
  font-weight: 800;
  font-display: optional;
  src: url("/assets/baloo-extrabold?v=4") format("woff2");
}

:root {
  color-scheme: light;

  --paper: #fff4dd;
  --ink: #26201a;
  --ink-2: #5c5347;
  --ink-3: #877b6b;

  --accent: #ff5c2b;
  --sun: #ffd84d;
  --rose: #ffb9cc;
  --sky: #a5dcff;
  --card: #fffdf7;

  --cg-empty: #f1e3c4;
  --cg-fill: var(--accent);

  --border: 2px solid var(--ink);
  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --radius: 14px;

  --font-display: "Baloo 2", "Arial Rounded MT Bold", system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --cell-size: 22px;
  --measure: 58ch;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

a:hover,
a:focus-visible {
  color: var(--accent);
}

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

.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 24px 72px;
}

/* ---------------------------------------------------------------------- */
/* Masthead                                                                */
/* ---------------------------------------------------------------------- */
.masthead {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 34px 0 10px;
  position: relative;
}

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

.masthead-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: var(--border);
  box-shadow: var(--shadow-sm);
  transform: rotate(-4deg);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.masthead-brand:hover .masthead-avatar {
  transform: rotate(4deg) scale(1.06);
}

.masthead-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(28px, 4.5vw, 36px);
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.05;
}

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

.masthead-side {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  white-space: nowrap;
}

.masthead-side:empty {
  display: none;
}

.subscription-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.push-control {
  position: relative;
}

.push-control[hidden] {
  display: none;
}

.subscription-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 8px 14px;
  border: var(--border);
  border-radius: 999px;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.push-toggle {
  background: var(--sun);
}

.push-toggle:hover {
  background: #ffe070;
}

.subscription-action:active {
  transform: translate(3px, 3px);
  box-shadow: 0 0 0 var(--ink);
}

.push-toggle[aria-pressed="true"] {
  background: var(--accent);
  color: var(--card);
}

.push-toggle:disabled {
  cursor: wait;
  opacity: 0.6;
}

.push-toggle-icon {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform-origin: 50% 15%;
}

.push-toggle:hover .push-toggle-icon {
  animation: bell-wiggle 0.5s ease;
}

@keyframes bell-wiggle {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-14deg); }
  55% { transform: rotate(11deg); }
  80% { transform: rotate(-5deg); }
}

.push-toggle[aria-pressed="true"] .push-toggle-icon {
  fill: currentColor;
}

.telegram-link {
  background: var(--card);
  text-decoration: none;
}

.language-toggle {
  background: var(--sky);
}

.language-toggle:hover {
  background: #c4eaff;
}

.telegram-link:focus-visible {
  background: var(--sky);
  color: var(--ink);
}

.telegram-link-icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.15s ease;
}

.telegram-link:focus-visible .telegram-link-icon {
  transform: translate(2px, -2px) rotate(-4deg);
}

@media (hover: hover) {
  .telegram-link:hover {
    background: var(--sky);
    color: var(--ink);
  }

  .telegram-link:hover .telegram-link-icon {
    transform: translate(2px, -2px) rotate(-4deg);
  }
}

.push-hint {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: max-content;
  max-width: 260px;
  white-space: normal;
  color: var(--ink-2);
  font-size: 13px;
  font-style: italic;
  line-height: 1.35;
  text-align: right;
  z-index: 2;
}

.push-hint:empty {
  display: none;
}

.demo-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--rose);
  border: var(--border);
  padding: 3px 9px;
  border-radius: 999px;
  box-shadow: 2px 2px 0 var(--ink);
  transform: rotate(2deg);
}

/* ---------------------------------------------------------------------- */
/* Hero                                                                    */
/* ---------------------------------------------------------------------- */
.hero {
  padding: 26px 0 0;
}

.hero-explainer {
  max-width: var(--measure);
  color: var(--ink-2);
  font-size: 17px;
  margin: 0 0 16px;
}

.hero > .subscription-actions {
  margin-bottom: 36px;
}

.hero-card {
  background: var(--card);
  background-image: radial-gradient(rgba(38, 32, 26, 0.1) 1.5px, transparent 1.5px);
  background-size: 18px 18px;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: 6px 6px 0 var(--ink);
  padding: 26px 30px 30px;
  transform: rotate(-0.4deg);
}

.hero-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 14px;
}

.hero-figure {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(40px, 7.5vw, 68px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--ink);
  background: var(--sun);
  padding: 0 16px 4px;
  border-radius: 10px;
  transform: rotate(-1.2deg);
  cursor: default;
  animation: pop-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes pop-in {
  from { transform: rotate(-1.2deg) scale(0.85); opacity: 0; }
  to { transform: rotate(-1.2deg) scale(1); opacity: 1; }
}

.hero-figure--muted {
  background: var(--cg-empty);
  font-size: clamp(26px, 5vw, 40px);
}

.hero-sub {
  margin: 14px 0 0;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-3);
  cursor: default;
}

/* Stat stickers */
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin: 34px 0 0;
  padding: 0;
}

.stat-tile {
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px 16px;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.stat-tile--sun { background: var(--sun); transform: rotate(-1deg); }
.stat-tile--rose { background: var(--rose); transform: rotate(0.8deg); }
.stat-tile--sky { background: var(--sky); transform: rotate(-0.6deg); }

.stat-tile:hover {
  transform: rotate(0deg) translateY(-3px);
}

.stat-tile dt {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0.75;
  margin: 0 0 4px;
}

.stat-label-short {
  display: none;
}

.stat-tile dd {
  margin: 0;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--ink);
  white-space: nowrap;
}

/* ---------------------------------------------------------------------- */
/* Section headings                                                        */
/* ---------------------------------------------------------------------- */
.section-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 18px;
}

.section-head h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.01em;
}

.section-sub {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
}

.legend-chip {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 3px;
  border: 1.5px solid var(--ink);
  background: var(--cg-empty);
  vertical-align: -1px;
}

.legend-chip--hit {
  background: var(--cg-fill);
}

.graph-section {
  padding: 46px 0 0;
}

.log-section {
  padding: 46px 0 8px;
}

/* ---------------------------------------------------------------------- */
/* Contribution graph                                                      */
/* ---------------------------------------------------------------------- */
.graph-card {
  background: var(--card);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px 14px;
}

.cg-container {
  display: flex;
  gap: 8px;
  max-width: 100%;
  position: relative;
}

.cg-weekdays {
  flex: none;
  display: grid;
  row-gap: 4px;
  column-gap: 4px;
}

.cg-weekday {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
}

.cg-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px;
  margin: -4px;
  max-width: 100%;
  scrollbar-width: thin;
}

.cg-grid {
  display: grid;
  row-gap: 4px;
  column-gap: 4px;
  position: relative;
}

.cg-month {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  align-self: start;
}

.cg-cell {
  width: var(--cell-size);
  height: var(--cell-size);
  border-radius: 6px;
  background: var(--cg-empty);
  border: none;
  padding: 0;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cg-cell[data-level="1"] {
  background: var(--cg-fill);
  border: 1.5px solid var(--ink);
  box-shadow: 1.5px 1.5px 0 var(--ink);
}

.cg-cell:hover,
.cg-cell:focus-visible {
  outline: none;
  transform: scale(1.22);
}

.cg-cell[data-level="1"]:hover,
.cg-cell[data-level="1"]:focus-visible {
  transform: scale(1.25) rotate(6deg);
}

.cg-cell--future {
  background: transparent;
  cursor: default;
}

.cg-cell--future:hover {
  transform: none;
}

.cg-tooltip {
  position: absolute;
  width: max-content;
  transform: translate(-50%, calc(-100% - 12px));
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.45;
  padding: 9px 11px;
  border-radius: 8px;
  max-width: 260px;
  pointer-events: none;
  z-index: 10;
  white-space: normal;
}

.cg-tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--ink);
}

.cg-tooltip-snippet {
  font-family: var(--font-body);
  opacity: 0.85;
}

/* ---------------------------------------------------------------------- */
/* Event log: speech bubbles                                               */
/* ---------------------------------------------------------------------- */
.log-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.log-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.log-avatar {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: var(--border);
  box-shadow: 2px 2px 0 var(--ink);
  margin-top: 4px;
}

.log-bubble {
  position: relative;
  flex: 1;
  min-width: 0;
  background: var(--card);
  border: var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 14px 18px 14px;
}

/* Speech-bubble tail pointing at the avatar */
.log-bubble::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 18px;
  width: 13px;
  height: 13px;
  background: var(--card);
  border-left: var(--border);
  border-bottom: var(--border);
  transform: rotate(45deg);
}

.log-item-meta {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.log-item-time {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  background: var(--sun);
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: 1px 10px 2px;
}

.log-item-abs {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}

.log-item-text {
  margin: 0;
  font-size: 16px;
  color: var(--ink);
  max-width: var(--measure);
}

.log-item-link {
  display: inline-block;
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.log-empty {
  color: var(--ink-2);
  font-size: 16.5px;
  font-style: italic;
}

/* ---------------------------------------------------------------------- */
/* Footer                                                                  */
/* ---------------------------------------------------------------------- */
.site-footer {
  margin-top: 52px;
  padding-top: 18px;
  border-top: var(--border);
  font-size: 13px;
  color: var(--ink-2);
}

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

.footer-fresh {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}

/* ---------------------------------------------------------------------- */
/* Reduced motion                                                          */
/* ---------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .hero-figure {
    animation: none;
  }

  .push-toggle:hover .push-toggle-icon {
    animation: none;
  }

  .telegram-link:hover .telegram-link-icon,
  .telegram-link:focus-visible .telegram-link-icon {
    transform: none;
  }

  .stat-tile,
  .cg-cell,
  .masthead-avatar,
  .subscription-action {
    transition: none;
  }
}

/* ---------------------------------------------------------------------- */
/* Responsive                                                              */
/* ---------------------------------------------------------------------- */
@media (max-width: 640px) {
  :root {
    --cell-size: 15px;
  }

  .page {
    padding: 0 16px 56px;
  }

  .masthead {
    padding-top: 24px;
    flex-wrap: wrap;
    row-gap: 12px;
  }

  .masthead-avatar {
    width: 40px;
    height: 40px;
  }

  .masthead-side {
    margin-left: auto;
  }

  .push-hint {
    max-width: min(260px, 76vw);
  }

  .hero-explainer {
    margin-bottom: 16px;
  }

  .hero > .subscription-actions {
    margin-bottom: 28px;
  }

  .hero-card {
    padding: 20px 18px 22px;
  }

  .hero-figure {
    padding: 0 10px 3px;
  }

  .section-head {
    flex-direction: column;
    gap: 4px;
  }

  .stat-row {
    gap: 12px;
  }

  .stat-tile {
    padding: 10px 12px 12px;
  }

  .stat-tile dt {
    font-size: 9px;
    letter-spacing: 0.04em;
    white-space: nowrap;
  }

  .stat-label-full {
    display: none;
  }

  .stat-label-short {
    display: inline;
  }

  .stat-tile dd {
    font-size: 22px;
  }

  .graph-card {
    padding: 12px 12px 10px;
  }

  .log-item {
    gap: 10px;
  }

  .log-avatar {
    width: 36px;
    height: 36px;
  }
}

/* Kept separate from the public tracker so the aaPanel administration views
   remain readable while the public page uses the supplied source styling. */
.admin { background: var(--paper); }
.admin-shell { width: min(880px, calc(100% - 48px)); margin: 0 auto; padding: 42px 0 72px; }
.admin-shell h1, .login-card h1 { font-family: var(--font-display); }
.admin-card, .login-card { margin: 18px 0; padding: 22px; border: var(--border); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.admin-card h2 { margin-top: 0; }
.admin-card code { font-family: var(--font-mono); font-size: 11px; }
.admin-event { padding: 12px 0; border-top: 1px dashed var(--ink-3); }
.admin-event p { margin: 6px 0; white-space: pre-line; }
.login-card { width: min(420px, calc(100% - 32px)); margin: 14vh auto 0; }
.login-card label { display: grid; gap: 7px; font-weight: 700; }
.login-card input { padding: 11px; border: var(--border); border-radius: 8px; font: inherit; }
.login-card button { margin-top: 16px; padding: 10px 14px; border: var(--border); border-radius: 999px; background: var(--sun); font-family: var(--font-display); font-weight: 700; }
