/* ============================================================
   HDL Review Lab — Mofuneko Brand Edition
   Design tokens aligned with mofuneko-hdl.com (style.css v5.0)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Noto+Sans+JP:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --header-height: 64px;

  /* Mofuneko Identity Colors */
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #0f172a;
  --sub: #334155;
  --muted: #64748b;
  --line: #e2e8f0;

  --primary: #63b3ed;        /* Mofuneko Blue (ears) */
  --primary-hover: #4299e1;
  --accent-purple: #9f7aea;  /* Mofuneko Purple (nose) */
  --accent-pink: #fc8181;    /* Mofuneko Pink (cheeks) */
  --brand-gradient: linear-gradient(135deg, var(--primary), var(--accent-purple));

  --green: #22c55e;
  --green-bg: #f0fdf4;
  --green-border: #86efac;
  --red: #ef4444;
  --red-bg: #fef2f2;
  --red-border: #fecaca;
  --amber: #d97706;
  --amber-bg: #fffbeb;
  --amber-border: #fde68a;

  --code-bg: #0f172a;
  --code-text: #e2e8f0;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --radius: 12px;
  --radius-lg: 16px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background-color: var(--bg);
  font-family: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}

button,
textarea {
  font: inherit;
}

button {
  border: 0;
}

/* ============================================================
   SITE HEADER (glassmorphism — matches main site)
   ============================================================ */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  z-index: 1000;
  display: flex;
  align-items: center;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-logo a {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.logo-mark {
  font-size: 1.4rem;
  display: inline-block;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.header-logo a:hover .logo-mark {
  transform: scale(1.2) rotate(15deg);
}

.logo-text {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.header-nav a {
  text-decoration: none;
  color: var(--sub);
  font-size: 0.95rem;
  font-weight: 600;
  transition: color 0.2s;
}

.header-nav a:hover {
  color: var(--primary);
}

/* ============================================================
   MOFUNEKO CHAT UI
   ============================================================ */
.mofuneko-chat {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  margin: 0 0 20px;
  padding: 1.5rem;
  background: var(--panel);
  border-radius: var(--radius-lg);
  border: 2px dashed #bfdbfe;
  box-shadow: var(--shadow-sm);
}

.chat-icon {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  border: 2px solid var(--primary);
}

.chat-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-bubble {
  background: white;
  padding: 1.25rem 1.5rem;
  border-radius: 0 var(--radius-lg) var(--radius-lg) var(--radius-lg);
  box-shadow: var(--shadow-sm);
  position: relative;
  font-size: 0.95rem;
  color: var(--text);
  font-weight: 500;
  line-height: 1.7;
  border: 1px solid #e2e8f0;
}

.chat-bubble::before {
  content: '';
  position: absolute;
  top: 0;
  left: -10px;
  border-width: 0 10px 10px 0;
  border-style: solid;
  border-color: transparent white transparent transparent;
}

.chat-bubble p {
  margin: 0;
}

.chat-bubble strong {
  color: var(--accent-pink);
}

/* ============================================================
   REVIEW SHELL (main wrapper)
   ============================================================ */
.review-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 24px;
  padding-top: calc(var(--header-height) + 24px);
}

/* ============================================================
   REVIEW HEADER
   ============================================================ */
.review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.review-header h1,
.lesson-intro h2,
.panel-head h3 {
  margin: 0;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.review-header h1 {
  font-size: 1.8rem;
  font-weight: 800;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.lesson-intro h2 {
  font-size: 1.4rem;
  font-weight: 800;
}

.panel-head h3 {
  font-size: 1rem;
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ============================================================
   PROGRESS CARD & STATUS PILL
   ============================================================ */
.progress-card,
.status-pill {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.progress-card {
  min-width: 132px;
  padding: 10px 14px;
  text-align: center;
}

.progress-card span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.progress-card strong {
  display: block;
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 800;
}

/* ============================================================
   LAYOUT GRID
   ============================================================ */
.review-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

/* ============================================================
   LESSON NAV (sidebar)
   ============================================================ */
.lesson-nav,
.lesson-main,
.code-panel,
.result-panel,
.reference-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow-md);
}

.lesson-nav {
  position: sticky;
  top: calc(var(--header-height) + 18px);
  max-height: calc(100vh - var(--header-height) - 36px);
  overflow: auto;
  padding: 16px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.lesson-nav::-webkit-scrollbar {
  width: 4px;
}

.lesson-nav::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.nav-head,
.panel-head,
.lesson-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.nav-head {
  margin-bottom: 12px;
  color: var(--sub);
  font-size: 0.9rem;
  font-weight: 800;
}

.nav-head button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: #eff6ff;
  color: var(--sub);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.nav-head button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  background: #dbeafe;
}

/* ============================================================
   LESSON CARDS
   ============================================================ */
.lesson-list {
  display: grid;
  gap: 8px;
}

.lesson-card {
  width: 100%;
  min-height: 82px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.lesson-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #bfdbfe;
}

.lesson-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.lesson-card.is-active {
  border-color: #bfdbfe;
  border-left-color: var(--accent-purple);
  background: #eff6ff;
  box-shadow: var(--shadow-md);
}

.lesson-card.is-done {
  border-left-color: var(--green);
}

.lesson-card strong,
.lesson-card span,
.lesson-card em {
  display: block;
}

.lesson-card strong {
  font-size: 0.96rem;
  line-height: 1.35;
  font-weight: 700;
}

.lesson-card span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-style: normal;
}

.lesson-card em {
  margin-top: 5px;
  color: var(--green);
  font-size: 0.74rem;
  font-style: normal;
  font-weight: 800;
}

/* ============================================================
   LESSON MAIN
   ============================================================ */
.lesson-main {
  padding: 20px;
}

.lesson-intro {
  align-items: flex-start;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.lesson-intro p {
  max-width: 78ch;
  margin: 8px 0 0;
  color: var(--sub);
}

.status-pill {
  min-width: 112px;
  padding: 8px 14px;
  color: var(--muted);
  text-align: center;
  font-weight: 800;
  font-size: 0.9rem;
}

.status-pill.is-pass {
  border-color: var(--green-border);
  background: var(--green-bg);
  color: #16a34a;
}

.status-pill.is-fail {
  border-color: var(--red-border);
  background: var(--red-bg);
  color: var(--red);
}

/* ============================================================
   CONCEPT CHIPS
   ============================================================ */
.concept-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 14px 0;
}

.concept-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #eff6ff;
  color: var(--primary-hover);
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid #bfdbfe;
}

/* ============================================================
   LAB GRID (code + results)
   ============================================================ */
.lab-grid {
  display: grid;
  grid-template-columns: minmax(420px, 0.95fr) minmax(460px, 1.05fr);
  gap: 16px;
}

.code-panel,
.result-panel,
.reference-panel {
  padding: 16px;
}

.code-panel {
  display: grid;
  grid-template-rows: auto minmax(430px, 1fr) auto;
  gap: 12px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.button-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  border-radius: var(--radius);
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  border: 1px solid var(--line);
}

.button {
  min-width: 84px;
  padding: 7px 14px;
  background: var(--panel);
  color: var(--text);
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  border-color: var(--primary);
}

.button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.button.primary {
  background: var(--brand-gradient);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(99, 179, 237, 0.3);
}

.button.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 179, 237, 0.4);
}

.button.hint {
  min-width: 76px;
  background: var(--amber-bg);
  border-color: var(--amber-border);
  color: var(--amber);
}

.button.hint:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.button.ghost {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: var(--primary-hover);
}

.button.ghost:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.icon-button {
  width: 38px;
  background: var(--panel);
  color: var(--sub);
}

.icon-button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  border-color: var(--primary);
  color: var(--primary);
}

/* ============================================================
   CODE EDITOR
   ============================================================ */
#codeEditor {
  width: 100%;
  min-height: 430px;
  resize: vertical;
  padding: 1rem 1rem 1rem 1.25rem;
  border: 1px solid #1e293b;
  border-radius: var(--radius);
  background: var(--code-bg);
  color: var(--code-text);
  font-family: 'JetBrains Mono', 'Consolas', 'Courier New', monospace;
  font-size: 0.9rem;
  line-height: 1.65;
  tab-size: 2;
  position: relative;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

#codeEditor:focus {
  outline: 2px solid rgba(99, 179, 237, 0.4);
  border-color: var(--primary);
}

/* Purple line bar on code panel (matches main site's pre::before) */
.code-panel::before {
  content: '';
  display: none;
}

.code-panel {
  position: relative;
  overflow: hidden;
}

.code-panel::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent-purple);
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

/* ============================================================
   MESSAGE BOX & HINT BOX
   ============================================================ */
.message-box,
.hint-box {
  min-height: 34px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: var(--sub);
  font-size: 0.9rem;
  line-height: 1.6;
}

.message-box.is-success {
  background: var(--green-bg);
  border-color: var(--green-border);
  color: #16a34a;
}

.message-box.is-error {
  background: var(--red-bg);
  border-color: var(--red-border);
  color: #b91c1c;
}

.hint-box {
  margin-top: 10px;
  background: var(--amber-bg);
  border-color: var(--amber-border);
  color: #92400e;
}

.hint-box:empty {
  display: none;
}

/* ============================================================
   RESULT TABLE
   ============================================================ */
.result-wrap {
  min-height: 430px;
  max-height: 560px;
  margin-top: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.result-table th,
.result-table td {
  min-width: 56px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: center;
  white-space: nowrap;
}

.result-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f1f5f9;
  color: var(--sub);
  font-size: 0.76rem;
  font-weight: 800;
}

.result-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

.result-table .output {
  font-weight: 800;
}

.result-table .pass {
  color: #16a34a;
}

.result-table .fail {
  background: var(--red-bg);
  color: var(--red);
}

.expected {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

/* ============================================================
   REFERENCE / CHECK LIST PANEL
   ============================================================ */
.reference-panel {
  margin-top: 16px;
}

.check-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.check-list li {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--sub);
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.check-list li.is-ok {
  border-color: var(--green-border);
  background: var(--green-bg);
  color: #16a34a;
}

.check-list li.is-warn {
  border-color: var(--amber-border);
  background: var(--amber-bg);
  color: #92400e;
}

/* ============================================================
   SITE FOOTER (matches main site)
   ============================================================ */
.site-footer {
  max-width: 1480px;
  width: 100%;
  margin: 2.5rem auto 0;
  padding: 2.5rem 24px 2rem;
  border-top: 1px solid var(--line);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.footer-brand .footer-logo {
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.footer-brand p {
  color: var(--muted);
  font-size: 0.85rem;
  max-width: 300px;
  margin: 0;
}

.footer-links {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--primary);
}

.footer-bottom {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
}

/* ============================================================
   RESPONSIVE — Tablet
   ============================================================ */
@media (max-width: 1140px) {
  .review-layout,
  .lab-grid {
    grid-template-columns: 1fr;
  }

  .lesson-nav {
    position: static;
    max-height: none;
  }

  .lesson-list {
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  }
}

/* ============================================================
   RESPONSIVE — Mobile
   ============================================================ */
@media (max-width: 680px) {
  .review-shell {
    padding: 14px;
    padding-top: calc(var(--header-height) + 14px);
  }

  .review-header,
  .lesson-intro,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .progress-card,
  .status-pill {
    width: 100%;
  }

  .lesson-main,
  .lesson-nav,
  .code-panel,
  .result-panel,
  .reference-panel {
    padding: 14px;
  }

  .button-row {
    width: 100%;
    justify-content: flex-start;
  }

  .button-row .button {
    flex: 1 1 96px;
  }

  .panel-head > .button {
    flex: 0 0 auto;
  }

  .icon-button {
    flex: 0 0 42px;
  }

  #codeEditor {
    min-height: 360px;
  }

  .result-wrap {
    min-height: 0;
    max-height: none;
  }

  .header-nav {
    gap: 0.75rem;
  }

  .header-nav a {
    font-size: 0.8rem;
  }

  .header-logo a {
    font-size: 1rem;
  }

  .mofuneko-chat {
    flex-wrap: wrap;
    padding: 1rem;
  }

  .chat-icon {
    width: 48px;
    height: 48px;
  }

  .chat-bubble {
    border-radius: var(--radius);
  }

  .chat-bubble::before {
    display: none;
  }

  .footer-inner {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

  .footer-links {
    justify-content: center;
  }
}
