/*
 * AgentAuth Architect - Stylesheet
 *
 * This file is loaded by index.html. Edit CSS variables in :root to change
 * the theme. Add new component styles below the relevant section.
 *
 * Do NOT edit index.html to change styles.
 */

:root {
      --bg: #fafaf9;
      --fg: #1c1917;
      --muted: #57534e;
      --card: #ffffff;
      --border: #e7e5e4;
      --accent: #0f766e;
      --accent-fg: #ffffff;
      --hover: #f5f5f4;
      --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
      --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
      --radius: 10px;
      --space: 1.5rem;
      --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
      --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
      --zone-internal: #2563eb;
      --zone-saas: #7c3aed;
      --zone-data: #059669;
      --zone-external: #ea580c;
      --zone-cross: #dc2626;
      --zone-protocol: #be185d;
      --zone-foundations: #475569;
    }
    [data-theme="dark"] {
      --bg: #0c0a09;
      --fg: #fafaf9;
      --muted: #a8a29e;
      --card: #1c1917;
      --border: #292524;
      --accent: #14b8a6;
      --accent-fg: #0c0a09;
      --hover: #292524;
      --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
      --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.5), 0 4px 6px -2px rgba(0,0,0,0.4);
    }
    * { box-sizing: border-box; margin: 0; padding: 0; }
    html { font-size: 16px; -webkit-text-size-adjust: 100%; }
    body {
      font-family: var(--font);
      background: var(--bg);
      color: var(--fg);
      line-height: 1.6;
      min-height: 100vh;
      min-height: 100dvh;
      transition: background 0.2s ease, color 0.2s ease;
      overflow-x: hidden;
    }
    .app { max-width: 1200px; margin: 0 auto; padding: 1.25rem 1rem; }

    .header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
    .brand { display: flex; align-items: center; gap: 0.75rem; min-width: 0; flex: 1 1 auto; }
    .logo {
      width: 36px; height: 36px; border-radius: 8px;
      background: linear-gradient(135deg, var(--accent), #14b8a6);
      display: flex; align-items: center; justify-content: center;
      color: var(--accent-fg); font-weight: 700; font-size: 18px;
      flex-shrink: 0;
    }
    .brand-text { min-width: 0; }
    h1 { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; }
    .subtitle { font-size: 0.875rem; color: var(--muted); }
    .header-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }
    .theme-toggle, .glossary-toggle {
      background: var(--card); border: 1px solid var(--border); color: var(--fg);
      padding: 0.5rem 0.75rem; border-radius: var(--radius); cursor: pointer;
      font-size: 0.875rem; font-family: var(--font);
      transition: all 0.15s ease;
      min-height: 38px;
    }
    .theme-toggle:hover, .glossary-toggle:hover { background: var(--hover); }
    .theme-toggle:focus-visible, .glossary-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

    .entry {
      max-width: 720px; margin: 4rem auto; padding: 2.5rem;
      background: var(--card); border: 1px solid var(--border);
      border-radius: var(--radius); box-shadow: var(--shadow);
    }
    .entry h2 {
      font-size: 1.5rem; font-weight: 600; margin-bottom: 0.5rem;
      letter-spacing: -0.02em;
    }
    .entry .lead { color: var(--muted); margin-bottom: 2rem; }
    .entry-options { display: grid; gap: 0.75rem; }
    .entry-option {
      display: flex; align-items: center; gap: 0.75rem;
      padding: 1rem 1.25rem; background: var(--bg);
      border: 1px solid var(--border); border-radius: var(--radius);
      cursor: pointer; font-size: 1rem; text-align: left;
      font-family: var(--font); color: var(--fg);
      transition: all 0.15s ease;
    }
    .entry-option:hover { border-color: var(--accent); background: var(--hover); }
    .entry-option:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
    .entry-option .icon {
      width: 32px; height: 32px; border-radius: 6px;
      display: flex; align-items: center; justify-content: center;
      background: var(--card); border: 1px solid var(--border);
      font-size: 14px; font-weight: 600;
    }
    .entry-option .text { flex: 1; }
    .entry-option .target { font-size: 0.75rem; color: var(--muted); }
    .skip-link {
      display: block; text-align: center; margin-top: 1.5rem;
      color: var(--muted); font-size: 0.875rem; cursor: pointer;
      background: none; border: none; font-family: var(--font);
      text-decoration: underline; text-underline-offset: 2px;
    }
    .skip-link:hover { color: var(--fg); }
    .footer {
      margin-top: 3rem; padding-top: 1.5rem;
      border-top: 1px solid var(--border);
      font-size: 0.8125rem; color: var(--muted);
      text-align: center; line-height: 1.6;
    }
    .footer a { color: var(--accent); text-decoration: none; }
    .footer a:hover { text-decoration: underline; }

    .tabs-container { display: none; }
    .tabs-container.active { display: block; }
    .tablist {
      display: flex; gap: 0.25rem; padding: 0.25rem;
      background: var(--card); border: 1px solid var(--border);
      border-radius: var(--radius); margin-bottom: 1.5rem;
      overflow-x: auto; scrollbar-width: thin;
      -webkit-overflow-scrolling: touch;
      scroll-snap-type: x proximity;
    }
    .tablist::-webkit-scrollbar { height: 4px; }
    .tablist::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
    .tab {
      flex: 0 0 auto; min-width: max-content; padding: 0.625rem 1rem;
      background: transparent; border: none; border-radius: 6px;
      color: var(--muted); font-size: 0.875rem; font-weight: 500;
      cursor: pointer; font-family: var(--font);
      transition: all 0.15s ease; white-space: nowrap;
      min-height: 38px;
      scroll-snap-align: start;
    }
    .tab:hover { color: var(--fg); background: var(--hover); }
    .tab[aria-selected="true"] {
      background: var(--accent); color: var(--accent-fg);
    }
    .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

    .panel { display: none; }
    .panel.active { display: block; }
    .panel-header { margin-bottom: 1.5rem; }
    .panel-header h2 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.02em; }
    .panel-header p { color: var(--muted); margin-top: 0.25rem; }

    /* Foundations (Agent Fundamentals) panel */
    .foundations-content { display: grid; gap: 1.5rem; }
    .foundation-card {
      background: var(--card); border: 1px solid var(--border);
      border-radius: var(--radius); padding: 1.5rem 1.75rem;
      position: relative;
    }
    .foundation-card h3 {
      font-size: 1.125rem; font-weight: 600; margin-bottom: 0.875rem;
      color: var(--accent);
      letter-spacing: -0.01em;
    }
    .foundation-card p { margin-bottom: 0.875rem; line-height: 1.7; }
    .foundation-card p:last-child { margin-bottom: 0; }
    .foundation-card code {
      font-family: var(--font-mono); font-size: 0.875rem;
      background: var(--bg); padding: 0.125rem 0.4375rem; border-radius: 4px;
      border: 1px solid var(--border);
    }
    .foundation-card ul, .foundation-card ol { margin: 0.875rem 0 1rem 1.5rem; }
    .foundation-card ul li, .foundation-card ol li { margin-bottom: 0.75rem; line-height: 1.65; }
    .foundation-card ol { padding-left: 1.25rem; }
    .foundation-card ol li::marker { font-weight: 700; color: var(--accent); }
    .foundation-card strong { color: var(--fg); font-weight: 600; }
    .anatomy-diagram {
      background: var(--bg); border: 1px solid var(--border);
      border-radius: var(--radius); padding: 1rem;
      margin: 1rem 0 0.5rem; overflow-x: auto;
      -webkit-overflow-scrolling: touch;
    }
    .anatomy-diagram svg { max-width: 100%; height: auto; }

    .scenarios { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
    .scenario-card {
      background: var(--card); border: 1px solid var(--border);
      border-radius: var(--radius); padding: 1.25rem;
      cursor: pointer; transition: all 0.15s ease;
      position: relative; overflow: hidden;
      min-height: 44px;
    }
    .scenario-card::before {
      content: ""; position: absolute; top: 0; left: 0;
      width: 4px; height: 100%; background: var(--zone-color, var(--accent));
    }
    .scenario-card:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px); }
    .scenario-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
    .zone-badge {
      display: inline-block; font-size: 0.6875rem; font-weight: 600;
      text-transform: uppercase; letter-spacing: 0.05em;
      padding: 0.125rem 0.5rem; border-radius: 4px;
      background: var(--zone-color, var(--accent)); color: white;
      margin-bottom: 0.75rem;
    }
    .scenario-card h3 { font-size: 1.0625rem; font-weight: 600; margin-bottom: 0.5rem; }
    .pattern-tag {
      display: inline-block; font-size: 0.8125rem;
      color: var(--muted); font-family: var(--font-mono);
      background: var(--bg); padding: 0.125rem 0.5rem; border-radius: 4px;
      margin-bottom: 0.75rem;
    }
    .scenario-card .desc { font-size: 0.875rem; color: var(--muted); line-height: 1.5; }

    .detail-backdrop {
      position: fixed; inset: 0; background: rgba(0,0,0,0.4);
      opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
      z-index: 40;
    }
    .detail-backdrop.open { opacity: 1; pointer-events: auto; }
    .detail {
      position: fixed; top: 0; right: 0; bottom: 0;
      width: 100%; max-width: 580px;
      background: var(--bg); border-left: 1px solid var(--border);
      box-shadow: var(--shadow-lg);
      transform: translateX(100%); transition: transform 0.25s ease;
      z-index: 50; overflow-y: auto;
      display: flex; flex-direction: column;
      overscroll-behavior: contain;
    }
    .detail.open { transform: translateX(0); }
    .detail-header {
      position: sticky; top: 0; background: var(--bg);
      border-bottom: 1px solid var(--border);
      padding: 1.25rem 1.5rem; display: flex;
      align-items: flex-start; justify-content: space-between; gap: 1rem;
      z-index: 1;
      padding-top: max(1.25rem, env(safe-area-inset-top));
    }
    .detail-header .meta { flex: 1; min-width: 0; }
    .detail-close {
      background: none; border: none; color: var(--muted);
      cursor: pointer; padding: 0.5rem; font-size: 1.5rem; line-height: 1;
      font-family: var(--font); border-radius: 4px;
      min-width: 44px; min-height: 44px;
      display: flex; align-items: center; justify-content: center;
      -webkit-tap-highlight-color: transparent;
    }
    .detail-close:hover { color: var(--fg); background: var(--hover); }
    .detail-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
    .detail-content { padding: 1.5rem; padding-bottom: max(1.5rem, env(safe-area-inset-bottom)); }
    .detail h2 { font-size: 1.375rem; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 0.5rem; }
    .detail .pattern-name {
      font-family: var(--font-mono); font-size: 0.875rem;
      color: var(--accent); margin-bottom: 1rem;
    }
    .detail-section { margin-bottom: 2.25rem; }
    .detail-section:last-child { margin-bottom: 0; }
    .detail-section h4 {
      font-size: 0.6875rem; font-weight: 700; text-transform: uppercase;
      letter-spacing: 0.08em; color: var(--muted); margin-bottom: 0.875rem;
    }
    .detail .description {
      font-size: 1rem; line-height: 1.65; color: var(--fg);
    }
    .detail code {
      font-family: var(--font-mono); font-size: 0.875em;
      background: var(--bg); padding: 0.125rem 0.375rem; border-radius: 3px;
      word-break: break-word; overflow-wrap: anywhere;
    }
    .controls-list { list-style: none; display: grid; gap: 0.625rem; }
    .controls-list li {
      display: flex; gap: 0.75rem; align-items: flex-start;
      font-size: 0.9375rem; line-height: 1.5;
    }
    .controls-list .check {
      flex-shrink: 0; width: 18px; height: 18px; border-radius: 4px;
      background: var(--zone-color, var(--accent)); color: white;
      display: flex; align-items: center; justify-content: center;
      font-size: 12px; font-weight: 700; margin-top: 2px;
    }
    .mermaid-container {
      background: var(--card); border: 1px solid var(--border);
      border-radius: var(--radius); padding: 1rem;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
    }
    .mermaid { display: flex; justify-content: center; min-width: 0; }
    .mermaid svg { max-width: 100%; height: auto; }
    .use-when {
      background: var(--card); border: 1px solid var(--border);
      border-radius: var(--radius); padding: 1rem 1.25rem;
    }
    .use-when p { font-size: 0.9375rem; line-height: 1.6; }
    .implementations {
      display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem;
    }
    .impl-tag {
      font-size: 0.75rem; padding: 0.25rem 0.625rem;
      background: var(--bg); border: 1px solid var(--border);
      border-radius: 4px; font-family: var(--font-mono);
    }
    .threat-box {
      background: color-mix(in srgb, #fee2e2 30%, transparent);
      border: 1px solid #fca5a5;
      border-radius: var(--radius); padding: 1rem 1.25rem;
    }
    [data-theme="dark"] .threat-box {
      background: color-mix(in srgb, #7f1d1d 30%, transparent);
      border-color: #b91c1c;
    }
    .threat-box h5 {
      font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
      letter-spacing: 0.05em; color: #b91c1c; margin-bottom: 0.5rem;
    }
    [data-theme="dark"] .threat-box h5 { color: #fca5a5; }
    .threat-list { list-style: none; display: grid; gap: 0.625rem; }
    .threat-list li {
      display: flex; gap: 0.625rem; align-items: flex-start;
      font-size: 0.875rem; line-height: 1.5;
    }
    .threat-list .threat-icon {
      flex-shrink: 0; font-size: 1rem; margin-top: 1px;
    }
    .attack-box {
      background: color-mix(in srgb, #fef3c7 30%, transparent);
      border: 1px solid #fbbf24;
      border-radius: var(--radius); padding: 1rem 1.25rem;
      font-size: 0.875rem; line-height: 1.5;
    }
    [data-theme="dark"] .attack-box {
      background: color-mix(in srgb, #78350f 30%, transparent);
      border-color: #d97706;
    }
    .attack-box h5 {
      font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
      letter-spacing: 0.05em; color: #b45309; margin-bottom: 0.5rem;
    }
    [data-theme="dark"] .attack-box h5 { color: #fbbf24; }
    .attack-box p { margin-bottom: 0.5rem; }
    .attack-box p:last-child { margin-bottom: 0; }
    .attack-box strong { font-weight: 600; }

    /* Glossary */
    .glossary-panel {
      position: fixed; top: 0; left: 0; bottom: 0;
      width: 100%; max-width: 500px;
      background: var(--bg); border-right: 1px solid var(--border);
      box-shadow: var(--shadow-lg);
      transform: translateX(-100%); transition: transform 0.25s ease;
      z-index: 50; overflow-y: auto;
      overscroll-behavior: contain;
    }
    .glossary-panel.open { transform: translateX(0); }
    .glossary-header {
      position: sticky; top: 0; background: var(--bg);
      border-bottom: 1px solid var(--border);
      padding: 1.25rem 1.5rem; display: flex;
      align-items: center; justify-content: space-between; gap: 1rem;
      z-index: 1;
      padding-top: max(1.25rem, env(safe-area-inset-top));
    }
    .glossary-header h2 { font-size: 1.25rem; font-weight: 600; }
    .glossary-content { padding: 1.5rem; padding-bottom: max(1.5rem, env(safe-area-inset-bottom)); }
    .glossary-search {
      width: 100%; padding: 0.625rem 0.875rem;
      background: var(--card); border: 1px solid var(--border);
      border-radius: var(--radius); font-size: 0.9375rem;
      font-family: var(--font); color: var(--fg);
      margin-bottom: 1.5rem;
    }
    .glossary-search:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
    .glossary-term {
      padding: 0.875rem 0; border-bottom: 1px solid var(--border);
    }
    .glossary-term:last-child { border-bottom: none; }
    .glossary-term-name {
      font-family: var(--font-mono); font-size: 0.9375rem;
      font-weight: 600; color: var(--accent); margin-bottom: 0.25rem;
    }
    .glossary-term-def {
      font-size: 0.9375rem; line-height: 1.55; color: var(--fg);
    }

    @media (max-width: 640px) {
      .app { padding: 0.875rem; }
      .header { gap: 0.75rem; margin-bottom: 1rem; }
      .header-actions { width: 100%; justify-content: flex-end; }
      .brand { flex: 1 1 auto; min-width: 0; }
      h1 { font-size: 1.0625rem; }
      .subtitle { font-size: 0.8125rem; }

      .entry { padding: 1.25rem; margin: 1.5rem auto; border-radius: 12px; }
      .entry h2 { font-size: 1.25rem; }
      .entry .lead { font-size: 0.9375rem; margin-bottom: 1.5rem; }
      .entry-option { padding: 0.875rem 1rem; font-size: 0.9375rem; }
      .entry-option .target { font-size: 0.6875rem; }

      .panel-header h2 { font-size: 1.25rem; }
      .panel-header p { font-size: 0.9375rem; }

      .foundation-card { padding: 1.125rem 1.25rem; }
      .foundation-card h3 { font-size: 1.0625rem; }
      .foundation-card p,
      .foundation-card ul li,
      .foundation-card ol li { font-size: 0.9375rem; }

      .tablist { margin-bottom: 1rem; }
      .tab { padding: 0.5rem 0.875rem; font-size: 0.8125rem; }

      .scenarios { grid-template-columns: 1fr; gap: 0.875rem; }
      .scenario-card { padding: 1rem; }
      .scenario-card h3 { font-size: 1rem; }
      .scenario-card .desc { font-size: 0.8125rem; }

      .detail {
        max-width: 100%; top: auto; height: auto;
        bottom: 0; left: 0; right: 0;
        border-left: none; border-top: 1px solid var(--border);
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
        max-height: 92vh;
        max-height: 92dvh;
      }
      .detail.open { transform: translateY(0); }
      .detail-header { padding: 1rem 1.125rem; }
      .detail-content { padding: 1.125rem; }
      .detail h2 { font-size: 1.25rem; }
      .detail .description { font-size: 0.9375rem; }
      .detail-section { margin-bottom: 1.75rem; }
      .detail-section h4 { font-size: 0.6875rem; margin-bottom: 0.75rem; }
      .use-when p { font-size: 0.875rem; }
      .controls-list li { font-size: 0.875rem; }
      .threat-list li { font-size: 0.8125rem; }
      .attack-box { font-size: 0.8125rem; padding: 0.875rem 1rem; }

      .glossary-panel { max-width: 100%; }
      .glossary-header { padding: 1rem 1.125rem; }
      .glossary-content { padding: 1.125rem; }
      .glossary-search { font-size: 1rem; min-height: 44px; }
      .glossary-term-def { font-size: 0.875rem; }

      .footer { font-size: 0.75rem; padding-top: 1rem; margin-top: 2rem; }
    }

    @media (max-width: 380px) {
      .header-actions { gap: 0.375rem; }
      .theme-toggle, .glossary-toggle { padding: 0.5rem 0.625rem; font-size: 0.8125rem; }
      .logo { width: 32px; height: 32px; font-size: 16px; }
    }

    @media (hover: none) {
      .scenario-card:hover { transform: none; }
      .scenario-card:active { background: var(--hover); }
      .entry-option:active { background: var(--hover); }
      .tab:active { background: var(--hover); color: var(--fg); }
    }

    @media (prefers-reduced-motion: reduce) {
      *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
      }
    }

    body.entry-shown .tabs-container { display: none; }
    body:not(.entry-shown) .entry { display: none; }
    body:not(.entry-shown) .tabs-container { display: block; }

    [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
