/* ============================================================
   phar.studio — reduziert, modern, Schwarzweiß + roter Akzent
   Mobile-first. Reines CSS, kein Framework.
   ============================================================ */

:root {
  --bg: #ffffff;
  --fg: #0a0a0a;
  --muted: #8a8a8a;
  --line: #e6e6e6;
  --accent: #ff3d00; /* Akzent (einheitlich mit The-Count-Panel) */

  --count-empty: #ececec;
  --count-filled: var(--fg);
  --count-today: var(--accent);

  --space: clamp(1.25rem, 5vw, 4rem);
  --font: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a;
    --fg: #f5f5f5;
    --muted: #7a7a7a;
    --line: #1e1e1e;
    --count-empty: #1c1c1c;
    --count-filled: #f5f5f5;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* ---------- Custom Cursor (roter Punkt) ---------- */
.cursor {
  position: fixed;
  top: 0;
  left: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  transition: transform 0.12s ease, opacity 0.2s ease, width 0.2s ease, height 0.2s ease;
  mix-blend-mode: normal;
  opacity: 0;
}
.cursor.is-active { opacity: 1; }
.cursor.is-hover {
  width: 34px;
  height: 34px;
  background: transparent;
  border: 1.5px solid var(--accent);
}
/* Auf Touch-/Zeigergeräten ohne Maus keinen Custom-Cursor erzwingen */
@media (hover: hover) and (pointer: fine) {
  body { cursor: none; }
  a, button, .hero__scroll { cursor: none; }
}

/* ---------- Layout ---------- */
main { display: block; }

section {
  padding: var(--space);
  min-height: 100vh; /* Fallback für ältere Browser */
  min-height: 100svh; /* iOS: kleinste sichtbare Höhe, kein Springen bei Adressleiste */
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* ---------- Hero ---------- */
.hero {
  align-items: flex-start;
  gap: 1.5rem;
  position: relative;
}

.hero__title {
  font-weight: 700;
  font-size: clamp(3rem, 18vw, 12rem);
  line-height: 0.92;
  letter-spacing: -0.04em;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
}

.hero__word {
  display: inline-block;
  opacity: 0;
  transform: translateY(0.35em);
  animation: rise 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.hero__word:nth-of-type(2) { animation-delay: 0.12s; }

.hero__dot {
  display: inline-block;
  width: 0.16em;
  height: 0.16em;
  margin: 0 0.05em;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: baseline;
  opacity: 0;
  transform: scale(0);
  animation: pop 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.42s forwards;
}

@keyframes rise {
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pop {
  0% { opacity: 0; transform: scale(0); }
  70% { transform: scale(1.25); }
  100% { opacity: 1; transform: scale(1); }
}

.hero__scroll {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--fg);
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0;
  animation: rise 0.9s cubic-bezier(0.16, 1, 0.3, 1) 0.7s forwards;
}
.hero__scroll:hover { color: var(--accent); }
.hero__arrow { animation: bob 1.8s ease-in-out infinite; }
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}

/* ============================================================
   The Count — Brutalist Year-Progress-Panel
   Eigene, in sich geschlossene Palette (Handoff-Vorgabe):
   Off-White #F2F2ED · Akzent #FF3D00 · Muted #8a8a85 · BG #000
   ============================================================ */
.count {
  align-items: center;      /* Panel horizontal zentrieren */
  background: #000;         /* Brutalist-Panel braucht schwarzen Hintergrund */
}

.count-panel {
  --cf: #f2f2ed;           /* off-white */
  --ca: #ff3d00;           /* accent */
  --cm: #8a8a85;           /* muted */
  position: relative;
  width: 700px;
  max-width: 100%;
  background: #000;
  border: 3px solid var(--cf);
  box-shadow: 12px 12px 0 0 var(--ca);
  padding: 36px 38px 0;
  color: var(--cf);
}

.count-panel .corner {
  position: absolute;
  font-family: "JetBrains Mono", monospace;
  color: var(--cf);
  font-size: 14px;
  line-height: 1;
}
.count-panel .corner.tl { top: 8px; left: 8px; }
.count-panel .corner.tr { top: 8px; right: 8px; }
.count-panel .corner.bl { bottom: 8px; left: 8px; }
.count-panel .corner.br { bottom: 8px; right: 8px; }

.count-panel .meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--cf);
}
.count-panel .status { display: flex; align-items: center; gap: 8px; color: var(--ca); }
.count-panel .status .dot {
  width: 8px;
  height: 8px;
  background: var(--ca);
  display: inline-block;
  animation: countDotBlink 1s steps(1) infinite;
}

.count-panel .rule { border-top: 3px solid var(--cf); margin: 18px 0 26px; }

.count-panel .count-hero { display: flex; align-items: flex-end; gap: 28px; margin-bottom: 26px; }
.count-panel .hero-number {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 128px;
  line-height: 0.82;
  letter-spacing: -5px;
  color: var(--cf);
  font-variant-numeric: tabular-nums;
}
.count-panel .hero-stats {
  border-left: 3px solid var(--cf);
  padding-left: 20px;
  padding-bottom: 8px;
  font-family: "JetBrains Mono", monospace;
}
.count-panel .hero-stats .of { font-size: 13px; letter-spacing: 2px; color: var(--cm); margin-bottom: 10px; }
.count-panel .hero-stats .pct { font-size: 22px; font-weight: 700; color: var(--ca); }
.count-panel .hero-stats .label { font-size: 11px; letter-spacing: 2px; color: var(--cm); margin-top: 2px; }

.count-panel .grid-frame { border: 2px solid var(--cf); padding: 10px; }
.count-panel .grid {
  display: grid;
  grid-template-rows: repeat(7, 9px);
  grid-auto-flow: column;
  grid-auto-columns: 9px;
  gap: 2px;
}
.count-panel .cell { width: 9px; height: 9px; box-sizing: border-box; }
.count-panel .cell.empty { background: transparent; border: 1px solid rgba(242, 242, 237, 0.25); }
.count-panel .cell.filled { background: var(--ca); }
.count-panel .cell.today { background: var(--cf); animation: countHardBlink 0.9s steps(1) infinite; }

.count-panel .footer-bar {
  display: flex;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--cf);
}
.count-panel .footer-bar .left { flex: 1; border-right: 2px solid var(--cf); padding: 14px 4px 14px 0; }
.count-panel .footer-bar .right { flex: 1; padding: 14px 0 14px 20px; color: var(--ca); }

.count-tooltip {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  background: #000;
  border: 2px solid #f2f2ed;
  color: #f2f2ed;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 6px 10px;
  box-shadow: 4px 4px 0 0 #ff3d00;
  white-space: nowrap;
  display: none;
}

@keyframes countHardBlink { 0%, 49% { background: #f2f2ed; } 50%, 100% { background: #ff3d00; } }
@keyframes countDotBlink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0.15; } }

/* Kleinere Screens: Panel-Abstände reduzieren und Zellen verkleinern, damit
   das komplette Jahr (7×~53) ohne horizontales Scrollen reinpasst. */
@media (max-width: 560px) {
  .count-panel { padding: 24px 20px 0; }
  .count-panel .hero-number { font-size: clamp(64px, 20vw, 128px); }
  .count-panel .count-hero { gap: 18px; }
  .count-panel .grid {
    grid-template-rows: repeat(7, 4px);
    grid-auto-columns: 4px;
    gap: 1px;
  }
  .count-panel .cell { width: 4px; height: 4px; }
}

/* ---------- Footer ---------- */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem var(--space);
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--muted);
}
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--accent); }

/* ---------- Impressum ---------- */
.legal {
  max-width: 46rem;
  min-height: auto;
  padding-top: calc(var(--space) * 1.5);
  gap: 1.25rem;
  justify-content: flex-start;
}
.legal h1 {
  font-weight: 700;
  font-size: clamp(2rem, 8vw, 3.5rem);
  letter-spacing: -0.03em;
}
.legal h2 {
  font-size: 1.1rem;
  margin-top: 1.5rem;
  letter-spacing: -0.01em;
}
.legal p { color: var(--fg); }
.legal p a { color: var(--accent); text-decoration: none; }
.legal p a:hover { text-decoration: underline; }
.legal .back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}
.legal .back:hover { color: var(--accent); }
.legal .muted { color: var(--muted); font-size: 0.85rem; }

/* ============================================================
   Hero-FX — zwei umschaltbare Reveal-Effekte
   ?fx=decode  (Default) · ?fx=glitch
   ============================================================ */

/* Gemeinsam: im FX-Modus sind die Buchstaben sofort da (kein Rise),
   der Effekt selbst ist der Auftritt. */
.fx-decode .hero__word,
.fx-glitch .hero__word {
  opacity: 1;
  transform: none;
  animation: none;
}

/* Beim Decode nicht umbrechen — verhindert Zeilen-Springen beim Scrambeln. */
.fx-decode .hero__title { white-space: nowrap; }

/* ---- Decode / Scramble ---- */
/* Punkt erscheint erst nach dem Entschlüsseln und blinkt scharf ein. */
.fx-decode .hero__dot {
  opacity: 0;
  transform: scale(1);
  animation: none;
}
.fx-decode .hero__dot.is-in {
  animation: dotBlink 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes dotBlink {
  0%   { opacity: 0; }
  15%  { opacity: 1; }
  25%  { opacity: 0; }
  45%  { opacity: 1; }
  55%  { opacity: 0; }
  70%  { opacity: 1; }
  100% { opacity: 1; }
}

/* ---- Glitch / RGB-Split ---- */
.fx-glitch .hero__title {
  position: relative;
  animation: glitchShake 1.4s linear 1;
}
.fx-glitch .hero__word { position: relative; }
.fx-glitch .hero__word::before,
.fx-glitch .hero__word::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.fx-glitch .hero__word::before {
  color: #ff2233;
  animation: glitchRed 1.4s linear 1 forwards;
}
.fx-glitch .hero__word::after {
  color: #16e9ff;
  mix-blend-mode: screen;
  animation: glitchCyan 1.4s linear 1 forwards;
}
.fx-glitch .hero__dot {
  transform: scale(1);
  animation: dotBlink 1.4s linear 1 forwards;
}
@keyframes glitchRed {
  0%   { transform: translate(-0.06em, 0.02em); clip-path: inset(0 0 62% 0); opacity: 1; }
  20%  { transform: translate(0.05em, -0.02em); clip-path: inset(42% 0 20% 0); }
  40%  { transform: translate(-0.04em, 0.01em); clip-path: inset(8% 0 70% 0); }
  60%  { transform: translate(0.04em, 0); clip-path: inset(72% 0 4% 0); }
  80%  { transform: translate(-0.02em, 0.01em); clip-path: inset(24% 0 40% 0); opacity: 1; }
  100% { transform: translate(0, 0); clip-path: inset(0 0 0 0); opacity: 0; }
}
@keyframes glitchCyan {
  0%   { transform: translate(0.06em, -0.02em); clip-path: inset(20% 0 42% 0); opacity: 1; }
  20%  { transform: translate(-0.05em, 0.02em); clip-path: inset(0 0 70% 0); }
  40%  { transform: translate(0.04em, -0.01em); clip-path: inset(60% 0 12% 0); }
  60%  { transform: translate(-0.04em, 0); clip-path: inset(30% 0 44% 0); }
  80%  { transform: translate(0.02em, -0.01em); clip-path: inset(70% 0 6% 0); opacity: 1; }
  100% { transform: translate(0, 0); clip-path: inset(0 0 0 0); opacity: 0; }
}
@keyframes glitchShake {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-3px, 1px); }
  30% { transform: translate(3px, -2px); }
  45% { transform: translate(-2px, 1px); }
  60% { transform: translate(2px, 1px); }
  75% { transform: translate(-1px, -1px); }
}

/* ============================================================
   Zoom-Transition: Hero zoomt beim Scrollen in den roten Punkt,
   dahinter erscheint The Count ("neue Seite").
   Nur aktiv, wenn JS die Klasse .zoom-on setzt → ohne JS bleibt
   das Layout normal gestapelt (Progressive Enhancement).
   ============================================================ */
.hero-wrap { position: relative; }

.zoom-on .hero-wrap {
  height: 220svh; /* Scroll-Strecke, über die der Zoom passiert */
}
.zoom-on .hero {
  position: sticky;
  top: 0;
  height: 100svh;
  min-height: 0;
  overflow: hidden; /* riesig skalierten Titel auf den Viewport beschneiden */
  will-change: transform;
}
.zoom-on .hero__title {
  position: relative;
  z-index: 1;
  will-change: transform, opacity;
}
.zoom-on .hero__scroll {
  position: relative;
  z-index: 1;
}

.zoom-veil {
  position: fixed;
  inset: 0;
  background: var(--accent);
  z-index: 50;
  pointer-events: none;
  /* Kreis-Maske wird per JS auf-/zugezogen → scharfe Kante (kein skaliertes Bitmap).
     Radius 0 = unsichtbar, füllt also im Ruhezustand nichts. */
  -webkit-clip-path: circle(0px at 50% 50%);
  clip-path: circle(0px at 50% 50%);
  will-change: clip-path;
}

/* ---------- Accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .hero__word, .hero__dot, .hero__tagline, .hero__scroll { opacity: 1; transform: none; }
}

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