/* ==========================================================================
   KubaOS toys.css - v1.1 M3
   Styles for the four fun apps (Calculator, Forklift, Tape Deck, Task
   Manager). References the shared design tokens declared in desktop.css
   (--navy, --amber, --paper, --ink, --radius-*, --font-*); never redeclares
   the palette. All four mount into a presenter container with no fixed size,
   so layouts use flex/grid and fill their host.
   ========================================================================== */

/* shared: every toy fills its host container */
.kt-calc,
.kt-fk,
.kt-tape,
.kt-tm {
  display: flex;
  flex-direction: column;
  height: 100%;
  box-sizing: border-box;
  font-family: var(--font-ui);
  color: var(--ink);
}

/* ==========================================================================
   C2 CALCULATOR
   ========================================================================== */

.kt-calc {
  padding: 10px;
  gap: 8px;
  background: var(--paper);
}

.kt-calc-lcd {
  background: var(--navy-deep);
  color: var(--green-term);
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 700;
  text-align: right;
  padding: 14px 12px;
  border-radius: var(--radius-btn);
  min-height: 30px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  letter-spacing: 0.5px;
}

.kt-calc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  flex: 1;
}

.kt-calc-eqrow {
  display: grid;
  grid-template-columns: 1fr;
}

.kt-calc-key {
  font-family: var(--font-ui);
  font-size: 17px;
  font-weight: 600;
  border: 1px solid rgba(28, 36, 51, 0.18);
  border-radius: var(--radius-btn);
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  padding: 12px 0;
  min-height: 44px;
  transition: background 90ms ease, transform 60ms ease;
}

.kt-calc-key:hover { background: #f0ece2; }
.kt-calc-key:active { transform: translateY(1px); }
.kt-calc-key:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }

.kt-calc-key.kt-calc-op {
  background: var(--navy);
  color: var(--paper);
  border-color: var(--navy);
}
.kt-calc-key.kt-calc-op:hover { background: #26334a; }

.kt-calc-key.kt-calc-fn {
  background: #e9e4d8;
  color: var(--ink-muted);
}
.kt-calc-key.kt-calc-fn:hover { background: #ddd6c6; }

.kt-calc-eq {
  width: 100%;
  background: var(--amber);
  color: var(--navy-deep);
  border-color: var(--amber);
  font-weight: 800;
}
.kt-calc-eq:hover { background: #f0ac2a; }

@media (prefers-reduced-motion: reduce) {
  .kt-calc-key { transition: none; }
}

/* ==========================================================================
   C3 FORKLIFT
   ========================================================================== */

.kt-fk {
  padding: 8px;
  gap: 6px;
  background: var(--navy);
  align-items: center;
  position: relative;
}

.kt-fk-hud {
  display: flex;
  justify-content: space-between;
  width: 100%;
  color: var(--amber-soft);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  padding: 0 4px;
}

.kt-fk-best { color: var(--ink-muted); }

.kt-fk-canvas {
  border: 1px solid var(--amber);
  border-radius: var(--radius-btn);
  background: var(--navy-deep);
  max-width: 100%;
  height: auto;
  display: block;
  touch-action: none;
}
.kt-fk-canvas:focus-visible { outline: 2px solid var(--amber-soft); outline-offset: 2px; }

.kt-fk-overlay {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  color: var(--amber-soft);
  border: 1px solid var(--amber);
  border-radius: var(--radius-btn);
  padding: 8px 14px;
  font-size: 13px;
  text-align: center;
  max-width: 90%;
  display: none;
}
.kt-fk-overlay.kt-show { display: block; }

/* ==========================================================================
   C4 TAPE DECK
   ========================================================================== */

.kt-tape {
  padding: 14px;
  gap: 14px;
  background: linear-gradient(180deg, #26334a 0%, var(--navy-deep) 100%);
  color: var(--paper);
  align-items: center;
}

.kt-tape-deck {
  width: 100%;
  background: var(--navy-deep);
  border: 1px solid var(--amber);
  border-radius: var(--radius-win);
  padding: 16px;
  box-sizing: border-box;
}

.kt-tape-reels {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.kt-tape-reel {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid var(--amber);
  background:
    radial-gradient(circle, var(--navy) 0 30%, transparent 31%),
    conic-gradient(from 0deg, var(--amber) 0 10%, transparent 10% 25%,
      var(--amber) 25% 35%, transparent 35% 50%,
      var(--amber) 50% 60%, transparent 60% 75%,
      var(--amber) 75% 85%, transparent 85% 100%);
  flex: 0 0 auto;
}

.kt-tape-label { text-align: center; flex: 1; }
.kt-tape-track { font-size: 16px; font-weight: 800; color: var(--amber-soft); }
.kt-tape-sub { font-size: 11px; color: var(--ink-muted); margin-top: 2px; }

.kt-tape-vu {
  margin-top: 14px;
  height: 26px;
  background: var(--paper);
  border-radius: var(--radius-btn);
  position: relative;
  overflow: hidden;
}
.kt-tape-needle {
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 2px;
  height: 22px;
  background: var(--navy);
  transform-origin: bottom center;
  transform: rotate(0deg);
}

.kt-tape-transport {
  display: flex;
  gap: 10px;
}
.kt-tape-btn {
  width: 52px;
  height: 44px;
  border: 1px solid var(--amber);
  border-radius: var(--radius-btn);
  background: var(--navy);
  color: var(--amber-soft);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
}
.kt-tape-btn:hover { background: #26334a; }
.kt-tape-btn:active { transform: translateY(1px); }
.kt-tape-btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }
.kt-tape-play { background: var(--amber); color: var(--navy-deep); border-color: var(--amber); }
.kt-tape-play:hover { background: #f0ac2a; }

.kt-tape-status {
  font-size: 12px;
  color: var(--ink-muted);
  text-align: center;
  min-height: 16px;
}

/* reels spin while playing; gated on reduced-motion (both media + body class
   + the JS static class) */
.kt-tape-spinning .kt-tape-reel { animation: kt-tape-spin 1.8s linear infinite; }
@keyframes kt-tape-spin { to { transform: rotate(360deg); } }

.kt-tape-spinning .kt-tape-needle { animation: kt-tape-vu 0.6s ease-in-out infinite alternate; }
@keyframes kt-tape-vu {
  0% { transform: rotate(-32deg); }
  100% { transform: rotate(30deg); }
}

@media (prefers-reduced-motion: reduce) {
  .kt-tape-spinning .kt-tape-reel,
  .kt-tape-spinning .kt-tape-needle { animation: none; }
}
.kt-reduce-fx .kt-tape-spinning .kt-tape-reel,
.kt-reduce-fx .kt-tape-spinning .kt-tape-needle,
.kt-tape-static .kt-tape-reel,
.kt-tape-static .kt-tape-needle { animation: none; }

/* ==========================================================================
   C5 TASK MANAGER
   ========================================================================== */

.kt-tm {
  background: var(--paper);
}

.kt-tm-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid rgba(28, 36, 51, 0.16);
  flex: 0 0 auto;
}
.kt-tm-tab {
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.kt-tm-tab:hover { color: var(--ink); }
.kt-tm-tab.kt-active { color: var(--ink); border-bottom-color: var(--amber); }
.kt-tm-tab:focus-visible { outline: 2px solid var(--amber); outline-offset: -2px; }

.kt-tm-pane { flex: 1; overflow: auto; min-height: 0; }

.kt-tm-head,
.kt-tm-row {
  display: grid;
  grid-template-columns: 1fr 64px 80px 88px;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 13px;
}
.kt-tm-head {
  color: var(--ink-muted);
  font-weight: 700;
  border-bottom: 1px solid rgba(28, 36, 51, 0.12);
  position: sticky;
  top: 0;
  background: var(--paper);
}
.kt-tm-list { margin: 0; padding: 0; list-style: none; }
.kt-tm-row { border-bottom: 1px solid rgba(28, 36, 51, 0.06); }
.kt-tm-row.kt-tm-sys { color: var(--ink-muted); font-style: italic; }
.kt-tm-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kt-tm-cpu, .kt-tm-mem { font-family: var(--font-mono); text-align: right; }
.kt-tm-act { text-align: right; }

.kt-tm-perf { padding: 14px; }
.kt-tm-perfhead { margin-bottom: 8px; }
.kt-tm-cpunow {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 800;
  color: var(--navy);
}
.kt-tm-chart {
  width: 100%;
  height: auto;
  border: 1px solid rgba(28, 36, 51, 0.18);
  border-radius: var(--radius-btn);
  background: var(--navy-deep);
  display: block;
}

/* desktop "restart" flicker on the desktop layer (Task Manager egg) */
.kt-tm-flicker { animation: kt-tm-flick 0.6s steps(2, end) 1; }
@keyframes kt-tm-flick {
  0% { opacity: 0; }
  40% { opacity: 1; }
  60% { opacity: 0.3; }
  100% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .kt-tm-flicker { animation: none; }
}

/* ==========================================================================
   v1.2 NIGHT SHIFT LOG. A battered paper logbook, not a modern app. The
   paper is CSS only: ruled lines, a margin rule, aged corners, one shadow.
   Everything here is static, so reduced motion needs no special handling.
   ========================================================================== */

.kt-nightlog-root {
  height: 100%;
  box-sizing: border-box;
  display: flex;
  padding: 10px;
  background: #41382c; /* the desk the book sits on */
}

.kt-nightlog {
  flex: 1;
  overflow-y: auto;
  box-sizing: border-box;
  padding: 20px 24px 28px 48px;
  background:
    linear-gradient(to right, transparent 33px, rgba(170, 80, 60, 0.35) 33px, rgba(170, 80, 60, 0.35) 34px, transparent 34px),
    radial-gradient(ellipse at 16% 6%, rgba(120, 90, 40, 0.16), transparent 55%),
    radial-gradient(ellipse at 86% 96%, rgba(90, 70, 30, 0.2), transparent 50%),
    repeating-linear-gradient(to bottom, transparent 0, transparent 27px, rgba(120, 105, 80, 0.22) 27px, rgba(120, 105, 80, 0.22) 28px),
    #efe5cc;
  color: #33291a;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.55;
  box-shadow: inset 0 0 38px rgba(70, 50, 20, 0.28);
  border-radius: 3px;
}

.kt-nightlog-head {
  font-weight: 700;
  letter-spacing: 3px;
  font-size: 1rem;
  color: #4a3a20;
}

.kt-nightlog-sub {
  margin: 4px 0 0;
  color: #6a5638;
  font-size: 0.78rem;
}

.kt-nightlog-entry { margin-top: 26px; }

.kt-nightlog-date {
  font-weight: 700;
  color: #5a4426;
  letter-spacing: 1px;
}

.kt-nightlog-entry p { margin: 6px 0 0; }

.kt-nightlog-spawn {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  font-weight: 700;
  color: #4a3a20;
}

/* an ink-stamped button, not a glossy one: the book stays a book */
.kt-nightlog-open {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 2px 10px;
  background: transparent;
  border: 1.5px solid #5a4426;
  border-radius: 3px;
  color: #5a4426;
  cursor: pointer;
}
.kt-nightlog-open:hover { background: rgba(90, 68, 38, 0.12); }
.kt-nightlog-open:focus-visible { outline: 2px solid #5a4426; outline-offset: 2px; }

.kt-nightlog-end {
  margin: 30px 0 0;
  color: #6a5638;
  font-size: 0.78rem;
}

/* ==========================================================================
   v1.2 CLOCK OFF. A one-page shift-handover sheet. On screen: a white page
   on the paper backdrop. In print (body.kt-print-clockoff): the sheet and
   nothing else. The visibility trick keeps the layout boxes so the fixed
   sheet can take the page.
   ========================================================================== */

.kt-clockoff-root {
  height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  background: var(--paper, #f6f3ec);
}

.kt-clockoff-sheet {
  flex: 1;
  overflow-y: auto;
  box-sizing: border-box;
  margin: 12px 12px 8px;
  padding: 18px 22px;
  background: #fff;
  border: 1px solid #cfc9bb;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
  color: #1c2433;
  font-family: var(--font-ui);
}

.kt-clockoff-title {
  font-weight: 800;
  letter-spacing: 2px;
  font-size: 1.05rem;
}

.kt-clockoff-sub {
  margin: 3px 0 12px;
  color: #5b6578;
  font-size: 0.8rem;
}

.kt-clockoff-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  padding: 7px 0;
  border-bottom: 1px dashed #d8d2c4;
  font-size: 0.86rem;
}

.kt-clockoff-label { color: #5b6578; flex-shrink: 0; }
.kt-clockoff-val { font-weight: 600; text-align: right; }

.kt-clockoff-foot {
  margin: 16px 0 0;
  font-size: 0.78rem;
  color: #5b6578;
}

.kt-clockoff-actions {
  display: flex;
  gap: 8px;
  padding: 0 12px 12px;
}

/* print: ONLY the sheet. visibility (not display) so ancestor boxes keep
   their place in the tree and the fixed-position sheet owns the page.
   Ancestor overflow is released so nothing crops. Needs a human print-
   preview pass; print bugs are invisible to code review. */
@media print {
  body.kt-print-clockoff * { visibility: hidden !important; }
  body.kt-print-clockoff .kt-clockoff-sheet,
  body.kt-print-clockoff .kt-clockoff-sheet * { visibility: visible !important; }
  body.kt-print-clockoff .kt-clockoff-sheet {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    padding: 14mm 16mm !important;
    border: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
    color: #111 !important;
    overflow: visible !important;
  }
  body.kt-print-clockoff .kt-window,
  body.kt-print-clockoff .kt-win-body,
  body.kt-print-clockoff .kt-app-host,
  body.kt-print-clockoff .kt-clockoff-root { overflow: visible !important; }
}
