/* =============================================================================
   Abbey – Retro Theme
   Memphis / 8-bit / 80s computer aesthetic.

   Loaded only when `Rails.application.config.theme == "retro"`. All
   declarations are scoped under `.theme-retro` (set on <html> by
   themes/retro/layouts/application.html.erb) so loading this file in any
   other context is a no-op.

   Color/shadow/font/animation TOKENS live in `app/assets/tailwind/application.css`
   under `@theme`, which makes Tailwind auto-generate the matching utility
   classes (`bg-memphis-pink`, `shadow-retro-lg`, `dark:text-memphis-mint`,
   `hover:bg-memphis-pink`, `animate-blink`, `text-[0.62rem]`, etc.) — no
   hand-rolled `.theme-retro .bg-foo-bar` declarations needed.

   This file ships:
     1. theme-root environmental styles (page bg, drifting confetti backdrop,
        CRT scanlines, selection color)
     2. font-family rebinding inside `.theme-retro` so utilities like
        `font-sans`, `font-mono`, `font-display` resolve to the retro stack
     3. component classes (`.card-retro`, `.btn-retro`, `.tag-retro`,
        `.h-display`, `.crt-window`, `.marquee`, `.date-sticker`,
        `.glitch-hover`, `.cursor-blink`)
     4. typography for the `.prose-retro` wrapper (h1-h3 with hard
        text-shadows, wavy-underline links, highlighted <strong>, terminal
        <pre> blocks, Memphis tables, dotted SVG <hr>)

   Palette: ink #0d0d12 · paper #fff8ef · crt #0a0e1a ·
            pink #ff3eb5 · cyan #00e5ff · yellow #ffd400 ·
            mint #00ff9c · purple #b14aff · coral #ff6b4a
============================================================================= */

/* ----------------------------------------------------------------------
   Font-family rebinding via CSS variable cascade.
   Tailwind generates `.font-sans`, `.font-mono`, `.font-display` as
   `{ font-family: var(--font-sans|mono|display) }`. Redefining those
   variables on `.theme-retro` makes every `font-*` utility inside the
   retro theme resolve to the retro font stack — without touching the
   default theme.
---------------------------------------------------------------------- */

.theme-retro {
  --font-sans:    "Space Grotesk", system-ui, sans-serif;
  --font-mono:    "VT323", ui-monospace, monospace;
  --font-display: "Press Start 2P", system-ui, sans-serif;
}

/* ----------------------------------------------------------------------
   Base – body backdrop, CRT scanlines, selection
---------------------------------------------------------------------- */

html.theme-retro {
  background-color: var(--color-memphis-paper);
  color: var(--color-memphis-ink);
  image-rendering: pixelated;
}
html.theme-retro.dark {
  background-color: var(--color-memphis-crt);
  color: #f0fff7;
}

html.theme-retro body {
  font-family: var(--font-sans);
  font-feature-settings: "ss01" on, "ss02" on;
  position: relative;
  overflow-x: hidden;
  min-height: 100vh;
}

/* Memphis confetti drifting in the background */
html.theme-retro body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.85;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='420' height='420' viewBox='0 0 420 420'><g fill='none' stroke-width='3' stroke-linecap='round'><circle cx='40' cy='60' r='6' fill='%23ff3eb5'/><circle cx='380' cy='90' r='4' fill='%2300e5ff'/><circle cx='130' cy='370' r='5' fill='%23ffd400'/><circle cx='290' cy='300' r='7' fill='%2300ff9c'/><path d='M70 200 q12 -16 24 0 t24 0 t24 0' stroke='%23b14aff'/><path d='M250 50 q10 -12 20 0 t20 0' stroke='%23ff6b4a'/><path d='M310 220 l14 -14 M310 220 l-14 14 M310 220 l14 14 M310 220 l-14 -14' stroke='%230d0d12'/><path d='M60 320 l16 -16 M60 320 l-16 16 M60 320 l16 16 M60 320 l-16 -16' stroke='%2300e5ff'/><polygon points='200,150 215,178 185,178' fill='%23ffd400' stroke='%230d0d12'/><polygon points='350,360 365,388 335,388' fill='%23ff3eb5' stroke='%230d0d12'/><rect x='160' y='40' width='14' height='14' fill='%2300ff9c' stroke='%230d0d12' transform='rotate(20 167 47)'/><rect x='40' y='240' width='10' height='10' fill='%23b14aff' stroke='%230d0d12' transform='rotate(15 45 245)'/></g></svg>");
  background-size: 420px 420px;
  animation: retro-drift 22s ease-in-out infinite;
}
html.theme-retro.dark body::before {
  opacity: 0.25;
  filter: hue-rotate(20deg) saturate(1.2);
}

/* Subtle CRT scanlines */
html.theme-retro body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0,
    rgba(0, 0, 0, 0) 3px,
    rgba(0, 0, 0, 0.022) 3px,
    rgba(0, 0, 0, 0.022) 4px
  );
  mix-blend-mode: multiply;
}
html.theme-retro.dark body::after {
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(0, 255, 156, 0) 0,
    rgba(0, 255, 156, 0) 3px,
    rgba(0, 255, 156, 0.028) 3px,
    rgba(0, 255, 156, 0.028) 4px
  );
  mix-blend-mode: screen;
}

html.theme-retro main,
html.theme-retro header,
html.theme-retro footer,
html.theme-retro nav,
html.theme-retro .content-layer {
  position: relative;
  z-index: 1;
}

html.theme-retro ::selection {
  background: var(--color-memphis-pink);
  color: var(--color-memphis-paper);
}
html.theme-retro.dark ::selection {
  background: var(--color-memphis-mint);
  color: var(--color-memphis-crt);
}

/* ----------------------------------------------------------------------
   Keyframes that are theme-local (drift/glitch don't need utilities).
   Note: blink / wiggle / pop-in / marquee are registered in @theme so
   Tailwind generates `animate-blink`, `animate-wiggle`, etc. and inlines
   the keyframes — they're not duplicated here.
---------------------------------------------------------------------- */

@keyframes retro-drift {
  0%, 100% { background-position: 0 0; }
  50%      { background-position: 80px 60px; }
}
@keyframes retro-glitch {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-2px, 2px); }
  40%  { transform: translate(2px, -1px); }
  60%  { transform: translate(-1px, -2px); }
  80%  { transform: translate(2px, 1px); }
  100% { transform: translate(0, 0); }
}

/* ----------------------------------------------------------------------
   Cards / containers
---------------------------------------------------------------------- */

.theme-retro .card-retro {
  background: #ffffff;
  border: 3px solid var(--color-memphis-ink);
  box-shadow: var(--shadow-retro);
  padding: 1.5rem;
  transition: transform 200ms ease, box-shadow 200ms ease;
}
.theme-retro.dark .card-retro {
  background: var(--color-memphis-crt);
  border-color: var(--color-memphis-mint);
  box-shadow: var(--shadow-retro-mint);
}
.theme-retro .card-retro:hover {
  transform: translate(-2px, -2px);
  box-shadow: var(--shadow-retro-lg);
}
.theme-retro.dark .card-retro:hover {
  box-shadow: 10px 10px 0 0 var(--color-memphis-mint);
}

.theme-retro .card-shadow-pink   { box-shadow: var(--shadow-retro-pink); }
.theme-retro .card-shadow-cyan   { box-shadow: var(--shadow-retro-cyan); }
.theme-retro .card-shadow-yellow { box-shadow: var(--shadow-retro-yellow); }
.theme-retro .card-shadow-mint   { box-shadow: var(--shadow-retro-mint); }
.theme-retro .card-shadow-purple { box-shadow: var(--shadow-retro-purple); }
.theme-retro .card-shadow-coral  { box-shadow: var(--shadow-retro-coral); }

/* ----------------------------------------------------------------------
   Buttons
---------------------------------------------------------------------- */

.theme-retro .btn-retro {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--color-memphis-yellow);
  color: var(--color-memphis-ink);
  border: 3px solid var(--color-memphis-ink);
  box-shadow: var(--shadow-retro);
  padding: 0.5rem 1rem;
  transition: transform 150ms ease, box-shadow 150ms ease;
  cursor: pointer;
}
.theme-retro .btn-retro:hover {
  transform: translate(2px, 2px);
  box-shadow: var(--shadow-retro-sm);
}
.theme-retro .btn-retro:active {
  transform: translate(4px, 4px);
  box-shadow: 0 0 0 0 transparent;
}
.theme-retro .btn-retro-pink   { background: var(--color-memphis-pink);   color: var(--color-memphis-paper); }
.theme-retro .btn-retro-cyan   { background: var(--color-memphis-cyan);   color: var(--color-memphis-ink); }
.theme-retro .btn-retro-mint   { background: var(--color-memphis-mint);   color: var(--color-memphis-ink); }
.theme-retro .btn-retro-purple { background: var(--color-memphis-purple); color: var(--color-memphis-paper); }
.theme-retro .btn-retro-coral  { background: var(--color-memphis-coral);  color: var(--color-memphis-paper); }
.theme-retro .btn-retro-ghost  { background: var(--color-memphis-paper);  color: var(--color-memphis-ink); }

.theme-retro .btn-icon-retro {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  background: var(--color-memphis-paper);
  color: var(--color-memphis-ink);
  border: 3px solid var(--color-memphis-ink);
  box-shadow: var(--shadow-retro-sm);
  transition: transform 150ms ease, box-shadow 150ms ease;
  cursor: pointer;
}
.theme-retro .btn-icon-retro:hover {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 0 transparent;
}
.theme-retro.dark .btn-icon-retro {
  background: var(--color-memphis-crt);
  color: var(--color-memphis-mint);
  border-color: var(--color-memphis-mint);
  box-shadow: none;
}

/* ----------------------------------------------------------------------
   Tag pills
---------------------------------------------------------------------- */

.theme-retro .tag-retro {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 1rem;
  line-height: 1;
  padding: 0.25rem 0.75rem;
  border: 2px solid var(--color-memphis-ink);
  box-shadow: var(--shadow-retro-sm);
  transition: transform 150ms ease;
}
.theme-retro .tag-retro:hover {
  transform: rotate(-2deg) scale(1.05);
}
.theme-retro .tag-color-1 { background: var(--color-memphis-pink);   color: var(--color-memphis-paper); }
.theme-retro .tag-color-2 { background: var(--color-memphis-cyan);   color: var(--color-memphis-ink); }
.theme-retro .tag-color-3 { background: var(--color-memphis-yellow); color: var(--color-memphis-ink); }
.theme-retro .tag-color-4 { background: var(--color-memphis-mint);   color: var(--color-memphis-ink); }
.theme-retro .tag-color-5 { background: var(--color-memphis-purple); color: var(--color-memphis-paper); }
.theme-retro .tag-color-6 { background: var(--color-memphis-coral);  color: var(--color-memphis-paper); }

/* ----------------------------------------------------------------------
   Pixel-display headings
---------------------------------------------------------------------- */

.theme-retro .h-display {
  font-family: var(--font-display);
  color: var(--color-memphis-ink);
  line-height: 1.4;
  letter-spacing: -0.02em;
  text-shadow: 3px 3px 0 var(--color-memphis-pink);
}
.theme-retro.dark .h-display {
  color: var(--color-memphis-mint);
  text-shadow: 3px 3px 0 var(--color-memphis-cyan);
}
.theme-retro .h-display-sm { font-size: 1rem; }
.theme-retro .h-display-md { font-size: 1.25rem; }
.theme-retro .h-display-lg { font-size: 1.5rem; }
@media (min-width: 640px) {
  .theme-retro .h-display-sm { font-size: 1.125rem; }
  .theme-retro .h-display-md { font-size: 1.5rem; }
  .theme-retro .h-display-lg { font-size: 1.875rem; }
}
@media (min-width: 768px) {
  .theme-retro .h-display-lg { font-size: 2.25rem; }
}

/* ----------------------------------------------------------------------
   Blinking terminal cursor + marquee
---------------------------------------------------------------------- */

.theme-retro .cursor-blink::after {
  content: "▮";
  display: inline-block;
  margin-left: 0.25rem;
  color: var(--color-memphis-pink);
  animation: var(--animate-blink);
}
.theme-retro.dark .cursor-blink::after { color: var(--color-memphis-mint); }

.theme-retro .marquee {
  overflow: hidden;
  white-space: nowrap;
  border-top: 3px solid var(--color-memphis-ink);
  border-bottom: 3px solid var(--color-memphis-ink);
  background: repeating-linear-gradient(
    45deg,
    var(--color-memphis-yellow) 0,
    var(--color-memphis-yellow) 18px,
    var(--color-memphis-ink) 18px,
    var(--color-memphis-ink) 36px
  );
  padding: 4px 0;
}
.theme-retro .marquee__track {
  display: inline-block;
  animation: var(--animate-marquee);
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--color-memphis-ink);
  background: var(--color-memphis-paper);
  padding: 6px 16px;
  border: 2px solid var(--color-memphis-ink);
}

/* ----------------------------------------------------------------------
   CRT-style code window + glitch hover
---------------------------------------------------------------------- */

.theme-retro .crt-window {
  position: relative;
  background: var(--color-memphis-crt);
  color: var(--color-memphis-mint);
  border: 3px solid var(--color-memphis-ink);
  box-shadow: var(--shadow-retro);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  overflow: hidden;
}
.theme-retro .crt-window::before {
  content: "● ● ●";
  display: block;
  background: var(--color-memphis-pink);
  color: var(--color-memphis-ink);
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 4px;
  padding: 6px 12px;
  border-bottom: 3px solid var(--color-memphis-ink);
}

.theme-retro .glitch-hover:hover {
  animation: retro-glitch 0.8s steps(1) 1;
}

/* ----------------------------------------------------------------------
   Date sticker (rotated label)
---------------------------------------------------------------------- */

.theme-retro .date-sticker {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 10px;
  background: var(--color-memphis-yellow);
  color: var(--color-memphis-ink);
  border: 2px solid var(--color-memphis-ink);
  padding: 4px 8px;
  transform: rotate(-3deg);
  box-shadow: 3px 3px 0 0 var(--color-memphis-ink);
}
.theme-retro .date-sticker--pink { background: var(--color-memphis-pink); color: var(--color-memphis-paper); }
.theme-retro .date-sticker--mint { background: var(--color-memphis-mint); color: var(--color-memphis-ink); }

/* ----------------------------------------------------------------------
   Rendered markdown content (`.prose-retro` wrapper)
   Used together with MinimalMarkdownRender (semantic HTML only).
---------------------------------------------------------------------- */

.theme-retro .prose-retro {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--color-memphis-ink);
}
.theme-retro.dark .prose-retro { color: #d6ffe9; }

.theme-retro .prose-retro h1,
.theme-retro .prose-retro h2,
.theme-retro .prose-retro h3 {
  font-family: var(--font-display);
  line-height: 1.5;
  margin: 2em 0 0.8em;
  letter-spacing: -0.02em;
}
.theme-retro .prose-retro h1 { font-size: 1.5rem;  color: var(--color-memphis-pink);   text-shadow: 3px 3px 0 var(--color-memphis-ink); }
.theme-retro .prose-retro h2 { font-size: 1.15rem; color: var(--color-memphis-purple); text-shadow: 2px 2px 0 var(--color-memphis-yellow); }
.theme-retro .prose-retro h3 { font-size: 0.95rem; color: #00a3cc; }

.theme-retro.dark .prose-retro h1 { color: var(--color-memphis-mint);   text-shadow: 3px 3px 0 var(--color-memphis-pink); }
.theme-retro.dark .prose-retro h2 { color: var(--color-memphis-yellow); text-shadow: 2px 2px 0 var(--color-memphis-ink); }
.theme-retro.dark .prose-retro h3 { color: var(--color-memphis-cyan); }

.theme-retro .prose-retro p { margin-bottom: 1.1em; }

.theme-retro .prose-retro strong {
  background: var(--color-memphis-yellow);
  color: var(--color-memphis-ink);
  padding: 0 4px;
  border: 2px solid var(--color-memphis-ink);
  font-weight: 700;
}
.theme-retro.dark .prose-retro strong {
  background: var(--color-memphis-mint);
  color: var(--color-memphis-crt);
  border-color: var(--color-memphis-mint);
}

.theme-retro .prose-retro em { font-style: italic; color: var(--color-memphis-purple); }
.theme-retro.dark .prose-retro em { color: var(--color-memphis-cyan); }

.theme-retro .prose-retro a {
  color: var(--color-memphis-pink);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-style: wavy;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}
.theme-retro .prose-retro a:hover { background: var(--color-memphis-yellow); color: var(--color-memphis-ink); }
.theme-retro.dark .prose-retro a { color: var(--color-memphis-mint); }
.theme-retro.dark .prose-retro a:hover { background: var(--color-memphis-pink); color: var(--color-memphis-paper); }

.theme-retro .prose-retro ul,
.theme-retro .prose-retro ol {
  margin: 1em 0 1.2em 1.5em;
  padding-left: 0.5em;
}
.theme-retro .prose-retro ul { list-style: none; }
.theme-retro .prose-retro ul > li::before {
  content: "▸ ";
  color: var(--color-memphis-pink);
  font-weight: 700;
  margin-right: 0.4em;
}
.theme-retro.dark .prose-retro ul > li::before { color: var(--color-memphis-mint); }
.theme-retro .prose-retro ol { list-style: decimal; }
.theme-retro .prose-retro li { margin-bottom: 0.4em; }

.theme-retro .prose-retro blockquote {
  border-left: 6px solid var(--color-memphis-pink);
  background: rgba(255, 212, 0, 0.18);
  padding: 1em 1.2em;
  margin: 1.5em 0;
  font-style: italic;
}
.theme-retro.dark .prose-retro blockquote {
  border-left-color: var(--color-memphis-mint);
  background: rgba(0, 229, 255, 0.08);
}

.theme-retro .prose-retro pre,
.theme-retro pre.highlight {
  background: var(--color-memphis-crt);
  color: var(--color-memphis-mint);
  border: 3px solid var(--color-memphis-ink);
  box-shadow: var(--shadow-retro-pink);
  padding: 1rem 1.1rem;
  margin: 1.5em 0;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  line-height: 1.4;
  position: relative;
}
.theme-retro.dark .prose-retro pre,
.theme-retro.dark pre.highlight {
  box-shadow: var(--shadow-retro-cyan);
  border-color: var(--color-memphis-mint);
}
.theme-retro .prose-retro pre::before,
.theme-retro pre.highlight::before {
  content: "● TERMINAL — RUN.EXE";
  display: block;
  font-family: var(--font-display);
  font-size: 9px;
  color: var(--color-memphis-yellow);
  letter-spacing: 2px;
  margin: -1rem -1.1rem 0.8rem;
  padding: 6px 12px;
  background: var(--color-memphis-ink);
  border-bottom: 2px solid var(--color-memphis-mint);
}

.theme-retro .prose-retro code,
.theme-retro code:not(pre code) {
  font-family: var(--font-mono);
  background: var(--color-memphis-yellow);
  color: var(--color-memphis-ink);
  padding: 0 6px;
  border: 2px solid var(--color-memphis-ink);
  font-size: 1em;
}
.theme-retro.dark .prose-retro code,
.theme-retro.dark code:not(pre code) {
  background: var(--color-memphis-pink);
  color: var(--color-memphis-crt);
  border-color: var(--color-memphis-crt);
}
.theme-retro .prose-retro pre code,
.theme-retro pre.highlight code {
  background: transparent;
  color: inherit;
  border: none;
  padding: 0;
  font-size: inherit;
}

.theme-retro .prose-retro hr {
  border: none;
  margin: 2em 0;
  height: 14px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='14' viewBox='0 0 40 14'><path d='M0 7 q5 -7 10 0 t10 0 t10 0 t10 0' fill='none' stroke='%23ff3eb5' stroke-width='3'/></svg>");
  background-repeat: repeat-x;
}
.theme-retro.dark .prose-retro hr {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='14' viewBox='0 0 40 14'><path d='M0 7 q5 -7 10 0 t10 0 t10 0 t10 0' fill='none' stroke='%2300ff9c' stroke-width='3'/></svg>");
}

.theme-retro .prose-retro img {
  border: 3px solid var(--color-memphis-ink);
  box-shadow: 6px 6px 0 0 var(--color-memphis-cyan);
  margin: 1.5em 0;
}

/* ----------------------------------------------------------------------
   Tables – Memphis: bold ink borders, neon header bar, drop shadow,
   subtle paper/yellow zebra. Scrolls horizontally on narrow screens.
---------------------------------------------------------------------- */

.theme-retro .prose-retro table {
  width: 100%;
  margin: 1.8em 0;
  border-collapse: separate;
  border-spacing: 0;
  border: 3px solid var(--color-memphis-ink);
  box-shadow: var(--shadow-retro-purple);
  background: var(--color-memphis-paper);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  overflow-x: auto;
  display: block;
}
.theme-retro.dark .prose-retro table {
  background: #14182a;
  border-color: var(--color-memphis-mint);
  box-shadow: var(--shadow-retro-pink);
}

.theme-retro .prose-retro thead      { background: var(--color-memphis-pink); }
.theme-retro.dark .prose-retro thead { background: var(--color-memphis-mint); }

.theme-retro .prose-retro th {
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-memphis-paper);
  text-shadow: 1px 1px 0 var(--color-memphis-ink);
  padding: 0.85em 1em;
  text-align: left;
  border-bottom: 3px solid var(--color-memphis-ink);
  border-right: 2px solid var(--color-memphis-ink);
}
.theme-retro.dark .prose-retro th {
  color: var(--color-memphis-crt);
  text-shadow: none;
  border-color: var(--color-memphis-crt);
}
.theme-retro .prose-retro th:last-child { border-right: none; }

.theme-retro .prose-retro td {
  padding: 0.7em 1em;
  border-bottom: 2px dashed var(--color-memphis-ink);
  border-right: 1px dashed rgba(13, 13, 18, 0.35);
  vertical-align: top;
}
.theme-retro.dark .prose-retro td {
  border-bottom-color: var(--color-memphis-mint);
  border-right-color: rgba(0, 255, 156, 0.25);
}
.theme-retro .prose-retro td:last-child { border-right: none; }
.theme-retro .prose-retro tbody tr:last-child td { border-bottom: none; }

.theme-retro .prose-retro tbody tr:nth-child(even)      { background: rgba(255, 212, 0, 0.18); }
.theme-retro.dark .prose-retro tbody tr:nth-child(even) { background: rgba(177, 74, 255, 0.12); }

.theme-retro .prose-retro tbody tr:hover      { background: rgba(0, 229, 255, 0.22); }
.theme-retro.dark .prose-retro tbody tr:hover { background: rgba(255, 62, 181, 0.18); }

.theme-retro .prose-retro td code,
.theme-retro .prose-retro th code {
  font-size: 0.9em;
  padding: 0 4px;
}
