/*
 * Retirement Countdown — Styles
 * Zero dependencies. Modern CSS. Layers for cascade control.
 *
 * EASTER_EGG: If you're reading this stylesheet, you clearly
 * have good taste. Treat yourself to something nice today.
 */

/* ── Layers ────────────────────────────────────────────────── */
@layer base, layout, components, effects, a11y;

/* ── Animated custom property for the progress bar ─────────── */
@property --progress {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 0%;
}

/* ── Base ──────────────────────────────────────────────────── */
@layer base {
  :root {
    --bg: #070a12;
    --panel: rgba(255 255 255 / 0.06);
    --panel2: rgba(255 255 255 / 0.09);
    --text: rgba(255 255 255 / 0.92);
    --muted: rgba(255 255 255 / 0.68);
    --faint: rgba(255 255 255 / 0.38);
    --border: rgba(255 255 255 / 0.10);

    --accent: #7c5cff;
    --accent2: #26d7ff;
    --good: #2dffb3;
    --warn: #ffd36e;

    --radius: 20px;
    --shadow: 0 18px 55px rgba(0 0 0 / 0.55);
    --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
      "Liberation Mono", "Courier New", monospace;
    --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto,
      Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  }

  @media (prefers-color-scheme: light) {
    :root {
      --bg: #f6f7fb;
      --panel: rgba(0 0 0 / 0.04);
      --panel2: rgba(0 0 0 / 0.06);
      --text: rgba(0 0 0 / 0.90);
      --muted: rgba(0 0 0 / 0.62);
      --faint: rgba(0 0 0 / 0.35);
      --border: rgba(0 0 0 / 0.10);
      --shadow: 0 18px 55px rgba(0 0 0 / 0.12);
      --accent: #5a3dff;
      --accent2: #0077ff;
      --good: #00b386;
      --warn: #b36b00;
    }
  }

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

  html,
  body {
    height: 100%;
  }

  body {
    margin: 0;
    font-family: var(--sans);
    color: var(--text);
    background: var(--bg);
    overflow-x: hidden;
  }
}

/* ── Layout ───────────────────────────────────────────────── */
@layer layout {
  main {
    min-height: 100%;
    display: grid;
    place-items: center;
    padding: clamp(16px, 3vw, 36px);
  }

  header {
    display: flex;
    gap: 14px;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    margin-bottom: 18px;
  }

  .grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 16px;
  }

  @media (max-width: 860px) {
    .grid {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }

  @media (max-width: 460px) {
    .grid {
      grid-template-columns: 1fr;
    }
  }

  .meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
    color: var(--muted);
    font-size: 13px;
  }

  .buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 18px;
  }
}

/* ── Components ───────────────────────────────────────────── */
@layer components {
  .card {
    width: min(980px, 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: linear-gradient(180deg, var(--panel), transparent);
    box-shadow: var(--shadow);
    padding: clamp(18px, 3.2vw, 34px);
    position: relative;
    overflow: hidden;
  }

  .card.done {
    border-color: rgba(45 255 179 / 0.30);
    background: linear-gradient(180deg, rgba(45 255 179 / 0.10), transparent);
  }

  h1 {
    margin: 0;
    font-size: clamp(26px, 3.4vw, 42px);
    letter-spacing: -0.02em;
    line-height: 1.05;
  }

  .subtitle {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 14px;
  }

  .pill {
    font-family: var(--mono);
    border: 1px solid var(--border);
    background: var(--panel2);
    padding: 10px 12px;
    border-radius: 999px;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
  }

  .tile {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255 255 255 / 0.02);
    padding: 14px 14px 12px;
  }

  .label {
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .value {
    margin-top: 6px;
    font-family: var(--mono);
    font-size: clamp(22px, 2.8vw, 34px);
    letter-spacing: -0.02em;
  }

  .value small {
    color: var(--faint);
    font-size: 0.55em;
    margin-left: 6px;
  }

  /* ── Progress bar ── */
  .bar-wrap {
    margin-top: 18px;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 10px;
    background: rgba(255 255 255 / 0.02);
  }

  .bar {
    height: 14px;
    border-radius: 999px;
    background: rgba(255 255 255 / 0.10);
    overflow: hidden;
    position: relative;
  }

  .bar-fill {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), var(--accent2), var(--good));
    width: var(--progress);
    transition: --progress 300ms ease;
  }

  .bar-shimmer {
    position: absolute;
    inset: 0;
    background: linear-gradient(
      90deg,
      rgba(255 255 255 / 0.06),
      rgba(255 255 255 / 0.00),
      rgba(255 255 255 / 0.06)
    );
    transform: translateX(-55%);
    animation: shimmer 3.2s linear infinite;
    opacity: 0.35;
    pointer-events: none;
  }

  /* ── Buttons ── */
  button {
    appearance: none;
    border: 1px solid var(--border);
    background: rgba(255 255 255 / 0.04);
    color: var(--text);
    border-radius: 14px;
    padding: 10px 12px;
    font-family: var(--mono);
    font-size: 12px;
    cursor: pointer;
    transition: transform 120ms ease, background 120ms ease;
  }

  button:hover {
    transform: translateY(-1px);
    background: rgba(255 255 255 / 0.07);
  }

  button:active {
    transform: translateY(0) scale(0.99);
  }

  button:focus-visible {
    outline: 2px solid rgba(124 92 255 / 0.55);
    outline-offset: 2px;
  }

  .footer {
    margin-top: 18px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.55;
  }

  .footer code {
    font-family: var(--mono);
    color: var(--text);
  }
}

/* ── Effects ──────────────────────────────────────────────── */
@layer effects {
  @keyframes shimmer {
    from { transform: translateX(-55%); }
    to   { transform: translateX(55%); }
  }

  .bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
      radial-gradient(1200px 900px at 15% 20%, rgba(124 92 255 / 0.30), transparent 55%),
      radial-gradient(1000px 850px at 85% 20%, rgba(38 215 255 / 0.22), transparent 55%),
      radial-gradient(900px 900px at 50% 85%, rgba(45 255 179 / 0.12), transparent 60%);
    filter: saturate(1.1);
  }

  @media (prefers-color-scheme: light) {
    .bg {
      background:
        radial-gradient(1200px 900px at 15% 20%, rgba(124 92 255 / 0.12), transparent 55%),
        radial-gradient(1000px 850px at 85% 20%, rgba(38 215 255 / 0.10), transparent 55%),
        radial-gradient(900px 900px at 50% 85%, rgba(45 255 179 / 0.06), transparent 60%);
    }
  }

  .noise {
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.06;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='260' height='260' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E");
  }

  .shine {
    position: absolute;
    inset: -40% -30%;
    background: conic-gradient(
      from 200deg,
      rgba(124 92 255 / 0.00),
      rgba(124 92 255 / 0.25),
      rgba(38 215 255 / 0.18),
      rgba(45 255 179 / 0.10),
      rgba(124 92 255 / 0.00)
    );
    filter: blur(26px);
    opacity: 0.30;
    transform: rotate(6deg);
    pointer-events: none;
  }
}

/* ── Accessibility ────────────────────────────────────────── */
@layer a11y {
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
  }

  @media (prefers-reduced-motion: reduce) {
    .bar-shimmer {
      animation: none;
    }

    button {
      transition: none;
    }

    .bar-fill {
      transition: none;
    }
  }
}
