/* Arduino LCD 8x8 — shared static theme (no CDN) */

:root {
  --bg-deep: #0a0e14;
  --bg-surface: #121820;
  --bg-elevated: #1a2332;
  --bg-card: #151d2a;
  --border: rgba(120, 194, 87, 0.18);
  --border-strong: rgba(0, 151, 157, 0.45);
  --text: #e8eef4;
  --text-muted: #8b9cb3;
  --text-dim: #5c6b80;
  --arduino-teal: #00979d;
  --arduino-green: #78c257;
  --arduino-teal-dark: #007a7f;
  --accent-glow: rgba(0, 151, 157, 0.35);
  --green-glow: rgba(120, 194, 87, 0.25);
  --lcd-bg: #1a3d1a;
  --lcd-pixel-on: #7dff6e;
  --lcd-pixel-off: #0f2410;
  --pixel-on: #00c9d0;
  --pixel-hover: #33dde3;
  --danger: #f87171;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-card: 0 24px 48px rgba(0, 0, 0, 0.45), 0 0 0 1px var(--border);
  --font-sans: "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "Cascadia Code", "Consolas", "Courier New", monospace;
  --nav-h: 64px;
  --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(0, 151, 157, 0.22), transparent),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(120, 194, 87, 0.12), transparent),
    radial-gradient(ellipse 50% 30% at 0% 100%, rgba(0, 151, 157, 0.08), transparent),
    var(--bg-deep);
}

a {
  color: var(--arduino-teal);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--arduino-green);
}

code {
  padding: 0.12rem 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-elevated);
  border-radius: 4px;
  color: var(--arduino-green);
}

img {
  max-width: 100%;
  height: auto;
}

/* ── Layout ── */

.container {
  width: min(1120px, 100% - 2rem);
  margin-inline: auto;
}

/* ── Nav ── */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 14, 20, 0.85);
  backdrop-filter: blur(12px);
}

.site-nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}

.brand:hover {
  color: var(--text);
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--arduino-teal), var(--arduino-green));
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  box-shadow: 0 0 20px var(--accent-glow);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links a {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: var(--arduino-green);
}

/* ── Hero ── */

.hero {
  padding: 0.75rem 0 0.25rem;
}

.hero-bullets {
  margin: 0.75rem 0 0;
  padding-left: 1.25rem;
  max-width: 720px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.hero-bullets li {
  margin-bottom: 0.35rem;
}

.hero-bullets li::marker {
  color: var(--arduino-teal);
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  margin-bottom: 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--arduino-green);
  background: rgba(120, 194, 87, 0.1);
  border: 1px solid rgba(120, 194, 87, 0.25);
  border-radius: 999px;
}

.hero h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.75rem, 5vw, 2.75rem);
  line-height: 1.15;
  font-weight: 800;
  background: linear-gradient(135deg, var(--text) 30%, var(--arduino-teal) 70%, var(--arduino-green));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-lead {
  margin: 0;
  max-width: 620px;
  font-size: 1.05rem;
  color: var(--text-muted);
}

.hero-lead strong {
  color: var(--arduino-teal);
  font-weight: 600;
}

/* ── Tool card (above fold — R-L3-03) ── */

.tool-card {
  margin: 0.5rem 0 3rem;
  padding: clamp(1rem, 3vw, 1.75rem);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  animation: card-enter 0.6s ease-out;
}

@keyframes card-enter {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tool-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.tool-card-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.tool-card-header p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.tool-workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .tool-workspace {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

/* ── Pixel grid ── */

.editor-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.grid-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.grid-wrap {
  padding: 1rem;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  display: inline-flex;
  align-self: flex-start;
}

.grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
  touch-action: none;
  user-select: none;
}

.cell {
  width: clamp(28px, 7vw, 38px);
  height: clamp(28px, 7vw, 38px);
  padding: 0;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  cursor: crosshair;
  font: inherit;
  color: inherit;
  appearance: none;
  -webkit-appearance: none;
  transition:
    background var(--transition),
    box-shadow var(--transition),
    transform var(--transition);
}

.cell:hover {
  border-color: rgba(0, 201, 208, 0.4);
  transform: scale(1.06);
}

.cell.on {
  background: var(--pixel-on);
  box-shadow:
    0 0 12px var(--accent-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  border-color: var(--arduino-teal);
  animation: pixel-pop 0.15s ease-out;
}

@keyframes pixel-pop {
  0% {
    transform: scale(0.85);
  }
  60% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

.cell.on:hover {
  background: var(--pixel-hover);
}

/* HD44780: col 0 + cols 6–7 are padding; cols 1–5 map to the physical cell */
.cell.pad-col {
  opacity: 0.38;
  background: rgba(10, 14, 20, 0.6);
}

.cell.pad-col.on {
  opacity: 0.55;
  background: rgba(0, 201, 208, 0.35);
}

/* ── LCD preview mockup ── */

.preview-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.lcd-mockup {
  padding: 1.25rem;
  background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 100%);
  border-radius: var(--radius-md);
  border: 2px solid #333;
  box-shadow:
    inset 0 2px 8px rgba(0, 0, 0, 0.5),
    0 8px 24px rgba(0, 0, 0, 0.4);
}

.lcd-screen {
  padding: 0.75rem 1rem;
  background: var(--lcd-bg);
  border-radius: 6px;
  box-shadow:
    inset 0 0 30px rgba(0, 0, 0, 0.4),
    0 0 20px rgba(125, 255, 110, 0.08);
  font-family: var(--font-mono);
  font-size: clamp(0.65rem, 2.5vw, 0.85rem);
  line-height: 1.4;
  color: var(--lcd-pixel-on);
  text-shadow: 0 0 8px rgba(125, 255, 110, 0.5);
  min-height: 4.5rem;
}

.lcd-screen.mode-2004 {
  min-height: 7rem;
  font-size: clamp(0.55rem, 2vw, 0.75rem);
}

.lcd-screen.mode-2004 .lcd-row {
  letter-spacing: 0.02em;
}

.lcd-row {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  white-space: pre;
}

.lcd-char-slot {
  display: inline-grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 1px;
  width: 2.2em;
  height: 2.8em;
  margin: 0 0.1em;
  vertical-align: middle;
  background: var(--lcd-pixel-off);
  border-radius: 2px;
  padding: 2px;
}

.lcd-pixel {
  background: var(--lcd-pixel-off);
  border-radius: 1px;
  transition: background 80ms ease;
}

.lcd-pixel.on {
  background: var(--lcd-pixel-on);
  box-shadow: 0 0 4px rgba(125, 255, 110, 0.6);
}

.lcd-label {
  margin-top: 0.65rem;
  font-size: 0.7rem;
  color: var(--text-dim);
  text-align: center;
}

/* ── Presets ── */

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.preset-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.65rem;
  min-width: 4.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    background var(--transition),
    border-color var(--transition),
    color var(--transition),
    transform var(--transition),
    box-shadow var(--transition);
}

.preset-mini {
  display: grid;
  grid-template-columns: repeat(8, 4px);
  gap: 1px;
  padding: 3px;
  background: #060a10;
  border-radius: 4px;
}

.preset-mini span {
  width: 4px;
  height: 4px;
  border-radius: 1px;
  background: var(--bg-elevated);
}

.preset-mini span.on {
  background: var(--pixel-on);
}

.preset-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.preset-btn.active {
  border-color: var(--arduino-teal);
  color: var(--arduino-teal);
  box-shadow: 0 0 0 1px var(--accent-glow);
}

.preset-btn:active {
  transform: translateY(0);
}

.slot-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.slot-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.slot-select {
  padding: 0.35rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.full-sketch-details {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.full-sketch-details summary {
  cursor: pointer;
  color: var(--arduino-teal);
  user-select: none;
}

.full-sketch-details[open] summary {
  margin-bottom: 0.5rem;
}

/* ── Code output ── */

.code-block {
  position: relative;
  margin-top: 0.5rem;
}

.code-block pre {
  margin: 0;
  padding: 1rem 1.25rem;
  background: #060a10;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: clamp(0.75rem, 2.5vw, 0.875rem);
  line-height: 1.5;
  color: var(--arduino-green);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.15rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    background var(--transition),
    transform var(--transition),
    box-shadow var(--transition);
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--arduino-teal), var(--arduino-teal-dark));
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-primary.copied {
  background: linear-gradient(135deg, var(--arduino-green), #5a9e3a);
  animation: copy-pulse 0.4s ease;
}

@keyframes copy-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.04);
  }
}

.btn-secondary {
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface);
}

.btn-ghost {
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
}

.btn-ghost:hover {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.3);
  background: rgba(248, 113, 113, 0.08);
}

/* ── Guides section ── */

.section-title {
  margin: 0 0 1.25rem;
  font-size: 1.5rem;
  font-weight: 700;
}

.guides-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 3rem;
}

@media (min-width: 640px) {
  .guides-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.guide-card {
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition:
    border-color var(--transition),
    transform var(--transition),
    box-shadow var(--transition);
}

.guide-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
}

.guide-card-icon {
  font-size: 1.5rem;
  margin-bottom: 0.65rem;
}

.guide-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.guide-card p {
  margin: 0 0 1rem;
  flex: 1;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.guide-card .read-more {
  font-size: 0.85rem;
  font-weight: 600;
}

/* ── Footer ── */

.site-footer {
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  text-align: center;
}

.site-footer p {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.site-footer a {
  font-size: 0.9rem;
  font-weight: 600;
}

/* ── Article / info pages ── */

.page-main {
  padding: 2rem 0 3rem;
}

.article-header {
  margin-bottom: 2rem;
}

.article-header h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  font-weight: 800;
  line-height: 1.2;
}

.article-meta {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.prose {
  max-width: 720px;
}

.prose h2 {
  margin: 2rem 0 0.75rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.prose h3 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.prose p,
.prose li {
  color: var(--text-muted);
}

.prose ul,
.prose ol {
  padding-left: 1.25rem;
}

.prose code {
  padding: 0.15rem 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-elevated);
  border-radius: 4px;
  color: var(--arduino-green);
}

.prose pre {
  padding: 1rem;
  background: #060a10;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

.prose pre code {
  padding: 0;
  background: none;
  color: var(--arduino-green);
}

.llm-citation-block {
  margin-top: 2rem;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  background: var(--bg-elevated);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

.llm-citation-block summary {
  cursor: pointer;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.llm-citation-block p {
  margin: 0.75rem 0 0;
  font-size: 0.8rem;
  line-height: 1.5;
}

.pin-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
}

.pin-table th,
.pin-table td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.pin-table th {
  color: var(--text);
  font-weight: 600;
  background: var(--bg-elevated);
}

.pin-table td {
  color: var(--text-muted);
}

.info-grid {
  display: grid;
  gap: 1rem;
  margin: 1.5rem 0;
}

@media (min-width: 640px) {
  .info-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.info-card {
  padding: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.info-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: var(--arduino-teal);
}

.info-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  font-weight: 600;
}
