/* ---------------------------------------------------------------
   Craft floor.
   --------------------------------------------------------------- */

:root {
  /* Hand-drawn zine palette */
  --paper: #FFFFFF;
  --ink: #2B2520;
  --ink-muted: #575757;
  --yellow: #FDE047;
  --pink: #FDA4AF;
  --teal: #2D7A5F;
  --rule: #E0E0E0;

  /* Typography scale: 1.125 ratio */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.5rem;
  --text-2xl: 2rem;
  --text-3xl: 3rem;

  /* Spacing scale: 4px base */
  --space-1: 0.5rem;
  --space-2: 0.75rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2rem;
  --space-6: 3rem;
  --space-8: 4rem;
  --space-10: 5rem;

  /* Readable line length */
  --measure: 75ch;

  scrollbar-color: var(--rule) transparent;
  caret-color: var(--ink);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Dark mode: desaturated and lifted, not inverted */
    --paper: #1A1816;
    --ink: #F5EFE7;
    --ink-muted: #B8AFA8;
    --yellow: #F0D84A;
    --pink: #ECA5AE;
    --teal: #5FAD8A;
    --rule: #3A3330;

    scrollbar-color: var(--rule) transparent;
    caret-color: var(--ink);
    color-scheme: dark;
  }
}

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

html {
  overflow-x: clip;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
}

p {
  text-wrap: pretty;
  margin: 0 0 var(--space-3) 0;
}

h1,
h2,
h3,
h4 {
  text-wrap: balance;
  margin: 0;
  font-weight: 700;
}

h1 {
  font-size: var(--text-3xl);
  letter-spacing: -0.02em;
  line-height: 1.1;
  position: relative;
}

h1::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 0;
  right: 0;
  height: 3px;
  background: repeating-linear-gradient(
    to right,
    var(--ink) 0,
    var(--ink) 8px,
    transparent 8px,
    transparent 16px
  );
  opacity: 0.3;
}

h2 {
  font-size: var(--text-2xl);
  letter-spacing: -0.01em;
  line-height: 1.2;
  font-weight: 700;
}

h3 {
  font-size: var(--text-xl);
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: var(--space-2);
}

h4 {
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: var(--space-2);
}

::selection {
  background: var(--yellow);
  color: var(--ink);
}

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

a {
  color: var(--teal);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 2px;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--ink);
}

code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.9em;
  background: rgba(43, 37, 32, 0.08);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  font-variant-numeric: tabular-nums;
}

ul, ol {
  margin: 0 0 var(--space-3) 0;
  padding-left: var(--space-4);
}

li {
  margin-bottom: var(--space-2);
  line-height: 1.7;
}

/* Main guide container */
.guide {
  max-width: 900px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5);
}

@media (max-width: 768px) {
  .guide {
    padding: var(--space-6) var(--space-4);
  }
}

@media (max-width: 480px) {
  .guide {
    padding: var(--space-4) var(--space-3);
  }

  body {
    font-size: 16px;
  }
}

/* Header */
.guide-header {
  margin-bottom: var(--space-8);
}

.header-content {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.intro {
  font-size: var(--text-lg);
  line-height: 1.7;
  color: var(--ink);
  max-width: var(--measure);
}

/* Router mascot */
.router-mascot {
  flex-shrink: 0;
}

@media (prefers-reduced-motion: no-preference) {
  .router-mascot:hover {
    transform: rotate(-5deg);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  }
}

.router-mascot.small {
  width: 60px;
  height: 60px;
}

@media (max-width: 480px) {
  .header-content {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }
}

/* Step sections */
.step-section {
  margin-bottom: var(--space-8);
}

.step-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.step-number {
  width: 48px;
  height: 48px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xl);
  font-weight: 700;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .step-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Highlight boxes */
.highlight-box {
  background: white;
  border-radius: 8px;
  padding: var(--space-4);
  margin: var(--space-4) 0;
  position: relative;
}

.highlight-box.yellow {
  border: 3px solid var(--yellow);
}

.highlight-box.pink {
  border: 3px solid var(--pink);
}

.highlight-box.teal {
  border: 3px solid var(--teal);
}

.highlight-box h3 {
  margin-top: 0;
}

.highlight-box ul,
.highlight-box ol {
  margin-bottom: 0;
}

/* Checklist */
.checklist {
  list-style: none;
  padding-left: 0;
}

.checklist li {
  position: relative;
  padding-left: var(--space-5);
}

.checklist li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--teal);
  font-weight: 700;
  font-size: 1.2em;
}

/* Diagrams */
.diagram {
  background: white;
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: var(--space-5);
  margin: var(--space-4) 0;
}

/* Flatten nested cards - remove card styling from container diagrams */
.diagram.features-diagram,
.diagram.password-diagram {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  margin: var(--space-6) 0;
}

/* Add spacing to replace removed container */
.diagram.features-diagram .diagram-inner,
.diagram.password-diagram .diagram-inner {
  margin-top: var(--space-4);
}

.diagram-inner {
  position: relative;
}

.diagram h3 {
  margin-top: 0;
  margin-bottom: var(--space-3);
}

.diagram-note {
  color: var(--ink-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-3);
}

@media (max-width: 768px) {
  .diagram {
    padding: var(--space-4);
  }
}

@media (max-width: 480px) {
  .diagram {
    padding: var(--space-3);
  }
}

/* Floor plan diagrams */
.floor-plan-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
}

@media (max-width: 768px) {
  .floor-plan-comparison {
    grid-template-columns: 1fr;
  }
}

.floor-plan {
  position: relative;
}

.plan-label {
  font-weight: 600;
  margin-bottom: var(--space-3);
  font-size: var(--text-sm);
}

.rooms {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  position: relative;
}

.room {
  aspect-ratio: 1;
  border: 2px solid var(--ink);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xl);
  position: relative;
}

.signal-wave {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
}

.good-signal {
  background: radial-gradient(circle, var(--teal) 0%, transparent 70%);
  opacity: 0.15;
  transform: scale(1.8);
}

.bad-signal {
  background: radial-gradient(circle, var(--pink) 0%, transparent 50%);
  opacity: 0.15;
  transform: scale(0.8);
}

.router-icon {
  font-size: 1.5em;
}

/* Channel diagrams */
.channels-24,
.channels-5 {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: var(--space-3);
}

.channel {
  min-width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--ink);
  border-radius: 4px;
  font-weight: 600;
  font-size: var(--text-sm);
  background: white;
}

.channel.recommended {
  border-width: 3px;
  background: var(--yellow);
  position: relative;
}

.channel.overlap {
  color: var(--ink-muted);
  border-style: dashed;
  border-color: var(--ink-muted);
}

.channel.available {
  border-color: var(--teal);
  background: rgba(45, 122, 95, 0.1);
}

@media (max-width: 480px) {
  .channels-24,
  .channels-5 {
    gap: 4px;
  }

  .channel {
    min-width: 36px;
    height: 36px;
    font-size: var(--text-xs);
  }
}

/* Network stack diagram */
.network-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.network-layer {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 2px solid var(--ink);
  align-items: center;
}

.network-layer.main {
  border-radius: 8px 8px 0 0;
  background: rgba(45, 122, 95, 0.03);
}

.network-layer.guest {
  border-radius: 0 0 8px 8px;
  border-top: none;
}

.network-divider {
  height: 2px;
  background: repeating-linear-gradient(
    to right,
    var(--ink) 0,
    var(--ink) 8px,
    transparent 8px,
    transparent 16px
  );
  margin: 0;
}

.network-icon {
  font-size: 2em;
  flex-shrink: 0;
}

.network-info {
  flex: 1;
  max-width: var(--measure);
}

.network-name {
  font-weight: 700;
  font-size: var(--text-lg);
  margin-bottom: var(--space-1);
}

.network-devices {
  font-size: var(--text-xl);
  margin-bottom: var(--space-1);
}

.network-status {
  color: var(--ink-muted);
  font-size: var(--text-sm);
  max-width: var(--measure, 75ch);
}

/* Feature grid */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
}

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

.feature-card {
  border: 2px solid var(--ink);
  border-radius: 6px;
  padding: var(--space-3);
  background: white;
}

.feature-card h3 {
  margin-top: 0;
  font-size: var(--text-base);
  position: relative;
  display: inline-block;
}

.feature-card h3::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--yellow);
  opacity: 0.6;
}

.feature-card p {
  margin: 0;
  font-size: var(--text-sm);
  line-height: 1.6;
}

/* Password examples */
.password-examples {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.password-example {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  border: 2px solid var(--rule);
  border-radius: 6px;
}

.password-example.weak {
  border-color: var(--pink);
  background: rgba(253, 164, 175, 0.05);
}

.password-example.medium {
  border-color: var(--yellow);
  background: rgba(253, 224, 71, 0.05);
}

.password-example.strong {
  border-color: var(--teal);
  background: rgba(45, 122, 95, 0.05);
}

.example-label {
  font-weight: 600;
  font-size: var(--text-sm);
  flex-shrink: 0;
}

.password-example code {
  font-weight: 600;
  background: transparent;
  padding: 0;
}

.example-note {
  color: var(--ink-muted);
  font-size: var(--text-xs);
  margin-left: auto;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .password-example {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-1);
  }

  .example-note {
    margin-left: 0;
  }
}

/* Mascot tips */
.mascot-tip {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  background: white;
  border: 3px solid var(--ink);
  border-radius: 8px;
  padding: var(--space-4);
  margin: var(--space-4) 0;
}

.doodle-arrow {
  flex-shrink: 0;
  margin-top: 10px;
}

.tip-bubble {
  flex: 1;
  font-size: var(--text-sm);
  line-height: 1.6;
  max-width: var(--measure, 75ch);
}

@media (max-width: 768px) {
  .doodle-arrow {
    display: none;
  }
}

@media (max-width: 480px) {
  .mascot-tip {
    flex-direction: column;
  }
}

/* Troubleshooting grid */
.troubleshooting-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  margin-top: var(--space-4);
}

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

.troubleshooting-card {
  background: white;
  border: 2px solid var(--ink);
  border-radius: 6px;
  padding: var(--space-3);
}

.troubleshooting-card h3 {
  margin-top: 0;
  font-size: var(--text-base);
  position: relative;
  display: inline-block;
}

.troubleshooting-card h3::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--yellow);
  opacity: 0.6;
}

.troubleshooting-card ul {
  margin: 0;
  padding-left: var(--space-4);
  font-size: var(--text-sm);
}

.troubleshooting-card li {
  margin-bottom: var(--space-2);
}

/* Footer */
.guide-footer {
  margin-top: var(--space-10);
  padding-top: var(--space-5);
  border-top: 2px dashed var(--rule);
  text-align: center;
  color: var(--ink-muted);
}

/* Print styles */
@media print {
  body {
    background: white;
    color: black;
    font-size: 12pt;
  }

  .guide {
    max-width: 100%;
    padding: 0;
  }

  .step-section {
    page-break-inside: avoid;
  }

  .diagram,
  .highlight-box,
  .mascot-tip {
    border-color: black;
  }

  .highlight-box::before {
    display: none;
  }

  a {
    color: black;
    text-decoration: underline;
  }

  .router-mascot,
  .doodle-arrow {
    display: none;
  }

  h1::after,
  .feature-card h3::after,
  .troubleshooting-card h3::after {
    display: none;
  }
}

/* Motion preferences */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }

  a {
    transition: color 0.2s ease;
  }
}
@media (max-width: 480px) {
  /* --impeccable-mobile-pad */
  body { padding-inline: max(1rem, 16px); }
  .container, [class*="container"], section, header, footer, nav, main, article {
    padding-inline: max(1rem, 16px);
  }
}
/* --impeccable-measure */
p, li, dt, dd, blockquote, figcaption, td, th { max-width: min(65ch, 100%); }

/* Ensure text containers enforce readable line length */
.highlight-box p,
.highlight-box li,
.highlight-box ol,
.highlight-box ul,
.feature-card p,
.troubleshooting-card p,
.troubleshooting-card li,
.troubleshooting-card ul,
.diagram-note,
.network-name,
.step-section > p {
  max-width: min(65ch, 100%);
}

/* Constrain heading widths for readability */
.step-section h2,
.step-section h3 {
  max-width: min(70ch, 100%);
}
