/* ============================================================
   phpspec.net — "Terminal Noir" Design System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,400;0,500;0,600;0,700;1,400&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #0a0c10;
  --bg-raised:    #0f1218;
  --bg-surface:   #151921;
  --bg-surface-2: #1a1f2b;
  --border:       #1e2535;
  --border-hover: #2a3347;
  --text:         #b0b8c9;
  --text-dim:     #636d80;
  --text-bright:  #e2e8f0;
  --heading:      #f0f4f8;

  --green:        #3dd68c;
  --green-dim:    rgba(61, 214, 140, .12);
  --cyan:         #22d3ee;
  --cyan-dim:     rgba(34, 211, 238, .08);
  --amber:        #f59e0b;
  --amber-dim:    rgba(245, 158, 11, .10);
  --red:          #ef4444;
  --red-dim:      rgba(239, 68, 68, .10);
  --violet:       #a78bfa;
  --violet-dim:   rgba(167, 139, 250, .10);
  --blue:         #60a5fa;
  --blue-dim:     rgba(96, 165, 250, .08);
  --rose:         #fb7185;
  --rose-dim:     rgba(251, 113, 133, .10);

  --code-bg:      #080a0e;
  --code-border:  #161c28;

  --font-body:    'DM Sans', system-ui, -apple-system, sans-serif;
  --font-mono:    'IBM Plex Mono', 'Menlo', 'Consolas', monospace;

  --max-w:        1240px;
  --header-h:     60px;
  --sidebar-w:    260px;
  --radius:       6px;
  --radius-lg:    10px;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
  scrollbar-color: var(--border) transparent;
}
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

/* Subtle noise overlay on body */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
}

a { color: var(--green); text-decoration: none; transition: color .15s; }
a:hover { color: var(--cyan); }
img { max-width: 100%; display: block; }
::selection { background: rgba(61, 214, 140, .2); color: var(--heading); }

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5 {
  color: var(--heading);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
h1 { font-size: 2.25rem; }
h2 { font-size: 1.55rem; margin-top: 3rem; margin-bottom: .85rem; }
h3 { font-size: 1.15rem; margin-top: 2rem; margin-bottom: .65rem; }
h4 { font-size: 1rem; margin-top: 1.5rem; margin-bottom: .5rem; color: var(--text-bright); }
p  { margin-bottom: 1rem; }
ul, ol { margin-bottom: 1rem; padding-left: 1.5rem; }
li { margin-bottom: .3rem; }
strong { color: var(--text-bright); font-weight: 600; }
hr { border: none; border-top: 1px solid var(--border); margin: 2.5rem 0; }

/* ---------- Layout ---------- */
.container { max-width: var(--max-w); margin: 0 auto; padding: 0 2rem; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 200;
  height: var(--header-h);
  background: rgba(10, 12, 16, .82);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
.site-header .container {
  display: flex; align-items: center; justify-content: space-between;
  height: 100%;
}
.logo {
  display: inline-flex; align-items: center; gap: .45rem;
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--heading);
  letter-spacing: -.02em;
}
.logo img {
  width: 28px; height: 28px;
  border-radius: 4px;
}

@keyframes blink {
  0% { opacity: 1; } 50% { opacity: 0; }
}

nav { display: flex; align-items: center; gap: 1.75rem; }
nav a {
  color: var(--text-dim);
  font-size: .875rem;
  font-weight: 500;
  transition: color .15s;
}
nav a:hover { color: var(--text-bright); }
nav a.active { color: var(--green); }
.nav-gh {
  display: inline-flex; align-items: center; gap: .4rem;
  border: 1px solid var(--border); padding: .35rem .85rem;
  border-radius: var(--radius); font-size: .8rem;
  color: var(--text-dim);
}
.nav-gh:hover { border-color: var(--border-hover); color: var(--text); }
.nav-gh svg { width: 16px; height: 16px; fill: currentColor; }

/* Mobile toggle */
.menu-toggle {
  display: none; background: none; border: none;
  color: var(--text); cursor: pointer; font-size: 1.4rem;
  line-height: 1;
}

/* ---------- Hero ---------- */
.hero {
  padding: 5rem 0 4rem;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute; top: -30%; left: 20%; transform: translateX(-50%);
  width: 800px; height: 800px;
  background: radial-gradient(circle, rgba(61, 214, 140, .06) 0%, transparent 70%);
  pointer-events: none;
}
.hero-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3.5rem;
  align-items: center;
}
.hero-left { position: relative; z-index: 1; }
.hero-right { position: relative; z-index: 1; }

.hero .version-badge {
  display: inline-flex; align-items: center; gap: .5rem;
  background: var(--green-dim); border: 1px solid rgba(61, 214, 140, .2);
  color: var(--green); font-family: var(--font-mono);
  font-size: .78rem; font-weight: 600;
  padding: .3rem .9rem; border-radius: 20px;
  margin-bottom: 1.5rem;
  letter-spacing: .02em;
}
.hero h1 {
  font-size: 2.8rem;
  font-weight: 700;
  letter-spacing: -.03em;
  margin-bottom: 1rem;
}
.hero h1 .accent { color: var(--green); }
.hero .subtitle {
  font-size: 1.05rem;
  color: var(--text-dim);
  margin-bottom: 1.5rem;
  line-height: 1.65;
}
.hero .ai-tagline {
  font-size: .92rem;
  color: var(--text);
  margin-bottom: 2rem;
  padding: .85rem 1rem;
  border-left: 3px solid var(--violet);
  background: var(--violet-dim);
  border-radius: 0 var(--radius) var(--radius) 0;
  line-height: 1.55;
}
.hero .ai-tagline strong { color: var(--violet); }

/* Install bar */
.install-bar {
  display: inline-flex; align-items: center; gap: .75rem;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: .65rem 1.35rem;
  border-radius: var(--radius-lg);
  font-family: var(--font-mono);
  font-size: .88rem;
  margin-bottom: 3.5rem;
}
.install-bar .prompt { color: var(--text-dim); user-select: none; }
.install-bar .cmd { color: var(--green); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .7rem 1.6rem;
  border-radius: var(--radius);
  font-weight: 600; font-size: .9rem;
  transition: all .15s;
  cursor: pointer; border: none;
}
.btn-primary {
  background: var(--green);
  color: var(--bg);
}
.btn-primary:hover {
  background: #4ae09a; color: var(--bg);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(61, 214, 140, .2);
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-ghost:hover {
  border-color: var(--green);
  color: var(--green);
}
.hero-actions {
  display: flex; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 2rem;
}

/* ---------- Animated terminal (hero) ---------- */
.hero-terminal { margin-bottom: 0; }
.hero-terminal .terminal-bar { position: relative; }
.hero-terminal .terminal-bar::after {
  content: 'phpspec pair';
  position: absolute; right: .85rem; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono); font-size: .65rem;
  color: var(--text-dim); letter-spacing: .02em;
}

/* Typewriter animation */
@keyframes typewriter {
  from { max-height: 0; }
  to   { max-height: 800px; }
}
@keyframes line-appear {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.typed-lines .tl {
  opacity: 0;
  animation: line-appear .3s ease forwards;
}
.typed-lines .tl:nth-child(1)  { animation-delay: .3s; }
.typed-lines .tl:nth-child(2)  { animation-delay: .8s; }
.typed-lines .tl:nth-child(3)  { animation-delay: 1.4s; }
.typed-lines .tl:nth-child(4)  { animation-delay: 1.7s; }
.typed-lines .tl:nth-child(5)  { animation-delay: 2.2s; }
.typed-lines .tl:nth-child(6)  { animation-delay: 2.5s; }
.typed-lines .tl:nth-child(7)  { animation-delay: 3.0s; }
.typed-lines .tl:nth-child(8)  { animation-delay: 3.3s; }
.typed-lines .tl:nth-child(9)  { animation-delay: 3.6s; }
.typed-lines .tl:nth-child(10) { animation-delay: 4.0s; }
.typed-lines .tl:nth-child(11) { animation-delay: 4.3s; }
.typed-lines .tl:nth-child(12) { animation-delay: 4.6s; }
.typed-lines .tl:nth-child(13) { animation-delay: 5.0s; }
.typed-lines .tl:nth-child(14) { animation-delay: 5.3s; }
.typed-lines .tl:nth-child(15) { animation-delay: 5.6s; }
.typed-lines .tl:nth-child(16) { animation-delay: 6.0s; }
.typed-lines .tl:nth-child(17) { animation-delay: 6.3s; }
.typed-lines .tl:nth-child(18) { animation-delay: 6.6s; }
.typed-lines .tl:nth-child(19) { animation-delay: 7.0s; }
.typed-lines .tl:nth-child(20) { animation-delay: 7.3s; }

/* Blinking cursor at end */
.typed-cursor {
  display: inline-block;
  width: 7px; height: 1.15em;
  background: var(--green);
  vertical-align: text-bottom;
  animation: blink 1s steps(2) infinite;
  margin-left: 1px;
}

/* AI glow accent on hero terminal */
.hero-terminal {
  position: relative;
}
.hero-terminal::before {
  content: '';
  position: absolute; top: -1px; left: -1px; right: -1px; bottom: -1px;
  border-radius: calc(var(--radius-lg) + 1px);
  background: linear-gradient(135deg, rgba(167, 139, 250, .25), rgba(61, 214, 140, .15), rgba(34, 211, 238, .2));
  z-index: -1;
  opacity: .6;
  filter: blur(1px);
}

/* ---------- Before/After Comparison ---------- */
.comparison-section {
  padding: 5rem 0;
  border-top: 1px solid var(--border);
}
.comparison-section h2 {
  text-align: center; margin-top: 0; margin-bottom: .5rem;
}
.comparison-section .subtitle {
  text-align: center; color: var(--text-dim); margin-bottom: 3rem;
}
.comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  max-width: 960px;
  margin: 0 auto;
}
.comparison-panel { position: relative; }
.comparison-label {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: .7rem; font-weight: 600;
  padding: .25rem .7rem; border-radius: 4px;
  margin-bottom: .6rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.label-before { background: var(--red-dim); color: var(--red); }
.label-after  { background: var(--green-dim); color: var(--green); }

/* ---------- Features Grid ---------- */
.features-section {
  padding: 5rem 0;
  border-top: 1px solid var(--border);
}
.features-section h2 {
  text-align: center; margin-top: 0; margin-bottom: .5rem;
}
.features-section .subtitle {
  text-align: center; color: var(--text-dim); margin-bottom: 3rem;
}
.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.feature-card {
  background: var(--bg-raised);
  padding: 1.75rem;
  transition: background .2s;
}
.feature-card:hover { background: var(--bg-surface); }
.feature-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: .85rem; font-weight: 700;
  margin-bottom: 1rem;
}
.fi-spec    { background: var(--green-dim); color: var(--green); }
.fi-mock    { background: var(--violet-dim); color: var(--violet); }
.fi-story   { background: var(--cyan-dim); color: var(--cyan); }
.fi-gen     { background: var(--amber-dim); color: var(--amber); }
.fi-cli     { background: var(--blue-dim); color: var(--blue); }
.fi-ext     { background: var(--rose-dim); color: var(--rose); }
.fi-ai      { background: var(--violet-dim); color: var(--violet); }
.fi-browser { background: var(--cyan-dim); color: var(--cyan); }
.fi-parallel{ background: var(--amber-dim); color: var(--amber); }
.feature-card h3 { margin-top: 0; font-size: 1rem; margin-bottom: .4rem; }
.feature-card p  { color: var(--text-dim); font-size: .88rem; margin-bottom: 0; line-height: 1.55; }

/* ---------- Code Blocks ---------- */
pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.5rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: .82rem;
  line-height: 1.7;
  margin-bottom: 1.5rem;
  color: var(--text);
  position: relative;
}
code {
  font-family: var(--font-mono);
  font-size: .85em;
}
p code, li code, td code {
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  padding: .1em .4em;
  border-radius: 3px;
  font-size: .82em;
  color: var(--text-bright);
  white-space: nowrap;
}

/* Syntax colors */
.c  { color: #4a5568; font-style: italic; }  /* comment */
.k  { color: var(--violet); }                  /* keyword */
.kn { color: var(--violet); }                  /* keyword namespace (use) */
.nf { color: var(--green); }                   /* function name */
.nc { color: var(--amber); }                   /* class name */
.s  { color: #34d399; }                        /* string */
.s2 { color: #34d399; }                        /* string double-quoted */
.mi { color: var(--amber); }                   /* number */
.nv { color: var(--cyan); }                    /* variable */
.na { color: var(--blue); }                    /* attribute / method */
.o  { color: var(--text-dim); }                /* operator */
.p  { color: var(--text-dim); }                /* punctuation */
.nx { color: var(--text-bright); }             /* other name */
.kr { color: var(--violet); font-weight: 600; }/* keyword reserved */

/* Code label badge */
.code-label {
  position: absolute; top: 0; right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--code-border);
  border-top: none; border-right: none;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: .65rem; font-weight: 600;
  padding: .2rem .6rem;
  border-radius: 0 var(--radius-lg) 0 var(--radius);
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ---------- Tables ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: .9rem;
}
th, td {
  text-align: left;
  padding: .6rem .75rem;
  border-bottom: 1px solid var(--border);
}
th {
  color: var(--text-dim);
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-family: var(--font-mono);
}
tr:hover td { background: var(--bg-raised); }

/* ---------- Callout ---------- */
.callout {
  border-left: 3px solid var(--green);
  background: var(--green-dim);
  padding: 1rem 1.25rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 1.5rem;
  font-size: .92rem;
}
.callout.warning {
  border-color: var(--amber);
  background: var(--amber-dim);
}
.callout.info {
  border-color: var(--blue);
  background: var(--blue-dim);
}
.callout strong { color: var(--heading); }

/* ---------- Manual Layout ---------- */
.manual-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 3rem;
  padding: 2rem 0 5rem;
  min-height: calc(100vh - var(--header-h));
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: calc(var(--header-h) + 1.5rem);
  height: fit-content;
  max-height: calc(100vh - var(--header-h) - 3rem);
  overflow-y: auto;
  padding-right: 1rem;
  border-right: 1px solid var(--border);
}
.sidebar::-webkit-scrollbar { width: 2px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-group { margin-bottom: 1.25rem; }
.sidebar-group-title {
  font-family: var(--font-mono);
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-dim);
  padding: 0 .75rem;
  margin-bottom: .35rem;
}
.sidebar a {
  display: block;
  padding: .3rem .75rem;
  font-size: .87rem;
  color: var(--text-dim);
  border-radius: var(--radius);
  border-left: 2px solid transparent;
  transition: all .12s;
  margin-bottom: 1px;
}
.sidebar a:hover {
  color: var(--text);
  background: var(--bg-surface);
}
.sidebar a.active {
  color: var(--green);
  background: var(--green-dim);
  border-left-color: var(--green);
}

/* Content area */
.manual-content {
  max-width: 780px;
  min-width: 0;
}
.manual-content h1 {
  margin-bottom: .5rem;
}
.manual-content .page-subtitle {
  color: var(--text-dim);
  font-size: 1.05rem;
  margin-bottom: 2rem;
  line-height: 1.6;
}
.manual-content h2 {
  padding-top: 1.5rem;
}
.manual-content h2:first-of-type {
  padding-top: 0;
}

/* ---------- Page Nav (Prev/Next) ---------- */
.page-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}
.page-nav a {
  display: block;
  padding: .85rem 1.15rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  flex: 1;
  transition: border-color .15s;
}
.page-nav a:hover {
  border-color: var(--green);
}
.page-nav .dir {
  font-family: var(--font-mono);
  font-size: .7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .15rem;
}
.page-nav .title {
  color: var(--text-bright);
  font-weight: 600;
  font-size: .92rem;
}
.page-nav .next { text-align: right; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2.5rem 0;
  color: var(--text-dim);
  font-size: .85rem;
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.footer-links {
  display: flex; gap: 1.5rem;
  list-style: none; padding: 0; margin: 0;
}
.footer-links a { color: var(--text-dim); }
.footer-links a:hover { color: var(--green); }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: .65rem;
  font-weight: 600;
  padding: .15rem .45rem;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: .04em;
  vertical-align: middle;
  margin-left: .35rem;
}
.badge-new     { background: var(--green-dim); color: var(--green); }
.badge-changed { background: var(--amber-dim); color: var(--amber); }

/* ---------- Terminal-style output block ---------- */
.terminal {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.terminal-bar {
  display: flex; align-items: center; gap: .4rem;
  padding: .5rem .85rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--code-border);
}
.terminal-dot {
  width: 10px; height: 10px; border-radius: 50%;
}
.terminal-dot.r { background: #ef4444; }
.terminal-dot.y { background: #f59e0b; }
.terminal-dot.g { background: #22c55e; }
.terminal-title {
  margin-left: .5rem;
  font-family: var(--font-mono);
  font-size: .72rem;
  color: var(--text-dim);
}
.terminal pre {
  border: none; border-radius: 0;
  margin: 0;
}
.terminal .out-green { color: var(--green); }
.terminal .out-red   { color: var(--red); }
.terminal .out-dim   { color: var(--text-dim); }
.terminal .out-cyan  { color: var(--cyan); }
.terminal .out-amber { color: var(--amber); }

/* ---------- Section heading anchors ---------- */
.anchor {
  color: var(--text-dim);
  opacity: 0;
  margin-left: .35rem;
  font-weight: 400;
  transition: opacity .15s;
}
h2:hover .anchor,
h3:hover .anchor { opacity: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .feature-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .manual-layout { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1.25rem;
    margin-bottom: 1.5rem;
    padding-right: 0;
  }
  .comparison-grid { grid-template-columns: 1fr; }
  .hero-split { grid-template-columns: 1fr; gap: 2rem; }
  .hero h1 { font-size: 2.4rem; }
}

@media (max-width: 640px) {
  nav:not(.open) { display: none; }
  .menu-toggle { display: block; }
  nav.open {
    display: flex; flex-direction: column;
    position: absolute; top: var(--header-h); left: 0; right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem; gap: .75rem;
    z-index: 100;
  }
  .hero { padding: 4rem 0 3rem; }
  .hero h1 { font-size: 1.9rem; }
  .container { padding: 0 1.25rem; }
  .feature-grid { grid-template-columns: 1fr; }
  .footer-inner { flex-direction: column; gap: 1rem; text-align: center; }
  .page-nav { flex-direction: column; }
}
