/* ─────────────────────────────────────────────
   runtime — styles
   ───────────────────────────────────────────── */


/* Design tokens
   ───────────────────────────────────────────── */
:root {
  /* surface */
  --bg:               #dbdbdb;
  --text:             #2a2a2a;

  /* terminal */
  --terminal-bg:      #f5f2ee;
  --terminal-text:    #2a2a2a;

  /* syntax */
  --comment-th:       #5a7a9a; /* italic */
  --comment-en:       #8a9aaa; /* italic */
  --keyword:          #4a6a8a;
  --string:           #6a8a5a;
  --number:           #8a6a3a;
  --fn:               #8a6a2a;
  --done:             #4a7a5a;
  --timestamp:        #aaaaaa;

  /* window chrome */
  --window-chrome:    #e8e4de;
  --window-border:    #c8c4be;

  /* bowl placeholder (until real images arrive) */
  --bowl-placeholder: #b8cfe0;

  /* typography */
  --font-wordmark:    'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-recipe:      'Roboto Slab', serif;
  --font-terminal:    'JetBrains Mono', monospace;
  --font-thai:        'Sarabun', sans-serif;

  --size-wordmark:    24px;
  --size-recipe:      16px;
  --size-terminal:    13px;

  --lh-terminal:      1.7;
  --ls-recipe:        0.32px;

  /* window geometry */
  --window-w:         820px;
  --window-h:         560px;
  --window-cascade:   24px;
}


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

a {
  color: inherit;
  text-decoration-color: inherit;
}


/* Base
   ───────────────────────────────────────────── */
html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-wordmark);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}


/* Wordmark
   ───────────────────────────────────────────── */
.site-header {
  width: 100%;
  display: flex;
  justify-content: center;
  padding-top: 28px;
  flex-shrink: 0;
}

.wordmark {
  font-family: var(--font-wordmark);
  font-size: var(--size-wordmark);
  font-weight: 400;
  color: var(--text);
  letter-spacing: 0;
  user-select: none;
}


/* Background overlay — bowl-background.png at 50% opacity
   ───────────────────────────────────────────── */
.bg-overlay {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: url('images/bowl-background.png');
  background-size: cover;
  background-position: center;
  opacity: 0.5;
  pointer-events: none;
}


/* Home screen
   ───────────────────────────────────────────── */
.home {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.recipe-list {
  width: 800px;
  display: flex;
  flex-wrap: wrap;
  gap: 80px;
  align-items: center;
  justify-content: center;
}


/* Recipe links
   ───────────────────────────────────────────── */
.recipe-link {
  font-family: var(--font-recipe);
  font-size: var(--size-recipe);
  font-weight: 400;
  letter-spacing: var(--ls-recipe);
  color: var(--text);
  white-space: nowrap;

  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;

  cursor: pointer;
  transition: opacity 0.12s ease;
}

.recipe-link:hover {
  opacity: 0.5;
}


/* Footer
   ───────────────────────────────────────────── */
.site-footer {
  width: 100%;
  height: 200px;
  flex-shrink: 0;
  background: linear-gradient(
    180deg,
    rgb(219, 219, 219)   0%,
    rgb(146, 212, 240)  11%,
    rgb(146, 212, 240)  22%,
    rgb(208, 161, 103)  37%,
    rgb(229, 145, 209)  45%,
    rgb(175, 190, 136)  72%,
    rgb(222,  86, 246)  85%,
    rgb( 75,  73, 203) 100%
  );
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
}

.footer-hint {
  font-family: var(--font-recipe);
  font-size: 16px;
  color: #f6ee56;
  letter-spacing: 0.32px;
  text-align: center;
  width: 100%;
  user-select: none;
}


/* Window layer (populated by window-manager.js)
   ───────────────────────────────────────────── */
#window-layer {
  position: fixed;
  inset: 0;
  z-index: 10;            /* above footer (z:5) */
  pointer-events: none;   /* windows opt back in individually */
}


/* ─────────────────────────────────────────────
   Window shell
   ───────────────────────────────────────────── */
.window {
  position: absolute;
  width:  var(--window-w);   /* 820px */
  height: var(--window-h);   /* 560px */

  display: flex;
  flex-direction: column;

  background: var(--window-chrome);
  border: 1px solid var(--window-border);
  border-radius: 8px;
  overflow: hidden;           /* clips corners on all children */

  /* The one permitted shadow — serves the window metaphor */
  box-shadow:
    0 2px  6px  rgba(0, 0, 0, 0.10),
    0 10px 40px rgba(0, 0, 0, 0.18);

  pointer-events: auto;       /* override #window-layer: none */
  user-select: none;
}


/* ── Title bar ───────────────────────────────── */
.window-titlebar {
  height: 28px;
  flex-shrink: 0;
  background: var(--window-chrome);
  border-bottom: 1px solid var(--window-border);

  display: flex;
  align-items: center;
  position: relative;         /* anchor for absolutely-placed traffic lights */
  cursor: default;
}

/* Traffic lights — positioned absolutely so title stays truly centred */
.traffic-lights {
  position: absolute;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 1;
}

.tl {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: none;
  padding: 0;
  cursor: default;
  flex-shrink: 0;
  appearance: none;
  -webkit-appearance: none;
}

.tl-red    { background: #ff5f57; }
.tl-yellow { background: #febc2e; }
.tl-green  { background: #28c840; }

.tl-red {
  cursor: pointer;
  transition: filter 0.1s ease;
}
.tl-red:hover  { filter: brightness(0.85); }
.tl-red:active { filter: brightness(0.70); }

/* Title: centered over the full title bar width */
.window-title {
  flex: 1;
  text-align: center;
  font-family: var(--font-wordmark);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.01em;
  pointer-events: none;
  user-select: none;
}


/* ── Body (terminal + bowl viewer) ───────────── */
.window-body {
  flex: 1;
  display: flex;
  overflow: hidden;    /* prevents flex children from blowing out */
  min-height: 0;       /* Firefox flex fix */
}


/* ── Terminal column (left) ──────────────────── */
.window-terminal {
  flex: 0 0 480px;
  background: var(--terminal-bg);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 20px;
  /* no box-shadow — see brief */
}

/* Thin scrollbar */
.window-terminal::-webkit-scrollbar       { width: 4px; }
.window-terminal::-webkit-scrollbar-track { background: transparent; }
.window-terminal::-webkit-scrollbar-thumb {
  background: var(--window-border);
  border-radius: 2px;
}

/* Terminal text lives here, lines injected by terminal.js */
.terminal-output {
  font-family: var(--font-terminal);
  font-size: var(--size-terminal);
  line-height: var(--lh-terminal);
  color: var(--terminal-text);
  white-space: pre;            /* preserve indentation */
}

/* Blinking block cursor */
.terminal-cursor {
  display: inline-block;
  width: 7px;
  height: 13px;
  background: var(--terminal-text);
  opacity: 0.55;
  vertical-align: text-top;
  animation: cursor-blink 1.1s step-end infinite;
}

@keyframes cursor-blink {
  0%, 100% { opacity: 0.55; }
  50%       { opacity: 0;    }
}


/* ── Column divider ──────────────────────────── */
.window-divider {
  flex-shrink: 0;
  width: 1px;
  background: var(--window-border);
}


/* ── Bowl viewer column (right) ──────────────── */
.window-bowl-viewer {
  flex: 1;
  background: var(--window-chrome);
  display: flex;
  align-items: center;
  justify-content: center;
  /* no box-shadow — see brief */
}

/* The bowl image / placeholder inside the window.
   CSS placeholder until bowl-*.png images are provided.
   On recipe completion, terminal.js swaps .bowl-empty → fills via img src. */
.bowl-in-viewer {
  width: 240px;
  height: 240px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: opacity 0.6s ease;   /* crossfade slot */
}

.bowl-empty {
  background-color: var(--bowl-placeholder);       /* fallback */
  background-image: url('images/bowl-empty.png');
  background-size: cover;
  background-position: center;
}


/* ── Status bar ──────────────────────────────── */
.window-statusbar {
  height: 24px;
  flex-shrink: 0;
  background: var(--window-chrome);
  border-top: 1px solid var(--window-border);

  display: flex;
  align-items: center;
  padding: 0 16px;
}

.statusbar-text {
  font-family: var(--font-terminal);
  font-size: 11px;
  color: var(--timestamp);
  letter-spacing: 0.02em;
}


/* ── Dragging state ──────────────────────────── */
/* Applied to body while a window is being dragged */
body.is-dragging,
body.is-dragging * {
  cursor: grabbing !important;
  user-select: none !important;
}


/* ── Footer z-ordering — footer is in normal flow, windows float above it */


/* ─────────────────────────────────────────────
   Terminal line types
   (injected into .terminal-output by terminal.js)
   ───────────────────────────────────────────── */

/* Base: each output row is a block */
.terminal-line {
  display: block;
  /* inherits: JetBrains Mono 13px / lh 1.7 / color from .terminal-output */
}

/* ── Blank line — one line of vertical rhythm ── */
.terminal-line.type-blank {
  height: calc(var(--size-terminal) * var(--lh-terminal)); /* 13px × 1.7 ≈ 22px */
}

/* ── Thai comment — Sarabun 200 italic ──────── */
.terminal-line.type-comment-th,
span.type-comment-th {
  font-family: var(--font-thai);
  font-weight: 200;
  font-style: italic;
  color: var(--comment-th);
}

/* ── English comment — italic, lighter ──────── */
.terminal-line.type-comment-en,
span.type-comment-en {
  font-style: italic;
  color: var(--comment-en);
}

/* ── Syntax token colours ────────────────────── */
.terminal-line.type-keyword,
span.type-keyword   { color: var(--keyword); }

.terminal-line.type-string,
span.type-string    { color: var(--string); }

.terminal-line.type-number,
span.type-number    { color: var(--number); }

.terminal-line.type-fn,
span.type-fn        { color: var(--fn); }

/* ── Completion line ─────────────────────────── */
.terminal-line.type-done,
span.type-done {
  color: var(--done);
}

/* ── Timestamp / muted annotations ──────────── */
.terminal-line.type-timestamp,
span.type-timestamp { color: var(--timestamp); }

/* ── Plain text (inside composite lines) ─────── */
span.type-text      { color: var(--terminal-text); }

/* ── Progress bar ────────────────────────────── */
/*
   Stays in JetBrains Mono so block chars (█ ░) render correctly.
   Color matches English comments — a system annotation.
*/
.terminal-line.type-progress {
  color: var(--comment-en);
  letter-spacing: 0;   /* block chars look better at 0 tracking */
}
