﻿/* JES · strohsahl.eu – styles of the home page */

:root {
  --bg:#050805; --fg:#1f9d55;
  /* Controls (hint, links): high contrast per palette, set in applyTheme() */
  --ui-fg:#bfe9cf; --ui-bg:rgba(5,8,5,.8); --ui-line:rgba(31,157,85,.35);
  --ui-ac:#eaffea; --ui-acl:rgba(234,255,234,.55); --ui-glow:0 0 10px rgba(234,255,234,.35);
}
html, body {
  margin:0; height:100%; overflow:hidden; background:var(--bg);
  user-select:none; -webkit-user-select:none; -webkit-tap-highlight-color:transparent;
}
canvas { position:fixed; inset:0; width:100%; height:100%; display:block; }
#art  { cursor:crosshair; touch-action:none; }
/* Edges: respect the notch/home bar (iPhone) */
:root {
  --sl:max(12px, env(safe-area-inset-left)); --sr:max(12px, env(safe-area-inset-right));
  --sb:max(10px, env(safe-area-inset-bottom)); --st:max(10px, env(safe-area-inset-top));
  --kb:0px;            /* height of the on-screen keyboard, via JS (visualViewport) */
}
/* Small badges: semi-transparent + blur behind them so they are readable on every pattern */
.chip {
  padding:4px 9px; font:11px/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color:var(--ui-fg); background:var(--ui-bg);
  border:1px solid var(--ui-line); border-radius:3px;
  -webkit-backdrop-filter:blur(4px); backdrop-filter:blur(4px);
}
/* Footer: terminal on the left, hint in the middle (truly centred), about + privacy on the right */
#foot {
  position:fixed; left:var(--sl); right:var(--sr); bottom:var(--sb);
  display:grid; grid-template-columns:1fr minmax(0, auto) 1fr; gap:8px; align-items:center;
  pointer-events:none;
}
#foot > * { pointer-events:auto; }
#tbtn { grid-column:1; justify-self:start; }
#hint { grid-column:2; }
#links { grid-column:3; justify-self:end; display:flex; gap:6px; }
#links a { text-decoration:none; opacity:.8; }
#links a:hover, #links a:focus-visible { opacity:1; text-decoration:underline; outline:none; }
/* >_ terminal: always visible, in the accent colour, with a blinking cursor */
#tbtn {
  margin:0; cursor:pointer; white-space:nowrap;
  color:var(--ui-ac); border-color:var(--ui-acl); box-shadow:var(--ui-glow);
  transition:box-shadow .3s, border-color .3s;
}
#tbtn:hover, #tbtn:focus-visible, #tbtn[aria-expanded="true"] {
  border-color:var(--ui-ac); outline:none; box-shadow:var(--ui-glow), 0 0 0 1px var(--ui-ac) inset;
}
#tbtn .cur { display:inline-block; animation:blink 1.1s steps(1) infinite; }
#tbtn[aria-expanded="true"] .cur { animation:none; opacity:0; }
@keyframes blink { 50% { opacity:0; } }
@media (prefers-reduced-motion: reduce) { #tbtn .cur { animation:none; } }
#hint {
  justify-self:center; min-width:0; max-width:100%;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  opacity:0; transition:opacity .8s;
}
#foot > #hint { pointer-events:none; }
#hint.on { opacity:1; }
/* Narrow screens: the hint does not fit between the badges -> top centre */
@media (max-width: 640px) {
  #hint {
    position:fixed; top:var(--st); left:50%; transform:translateX(-50%);
    max-width:calc(100vw - 24px);
  }
}

/* The hidden terminal – sits above the corner and moves up when the keyboard is shown */
#term {
  position:fixed; left:var(--sl); right:var(--sr); bottom:calc(var(--sb) + 32px + var(--kb));
  max-width:780px; max-height:min(55vh, 420px); display:flex; flex-direction:column;
  font:13px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  color:var(--ui-fg); background:var(--ui-bg); border:1px solid var(--ui-line); border-radius:4px;
  -webkit-backdrop-filter:blur(8px); backdrop-filter:blur(8px);
  box-shadow:0 8px 30px rgba(0,0,0,.35);
  user-select:text; -webkit-user-select:text;
}
#term.kb { bottom:calc(var(--kb) + 8px); max-height:calc(var(--vvh, 100vh) - var(--st) - 16px); }
#term[hidden] { display:none; }
#tout {
  overflow-y:auto; padding:10px 12px 0; white-space:pre-wrap; word-break:break-word;
  scrollbar-width:thin; scrollbar-color:var(--ui-line) transparent;
}
#tout::-webkit-scrollbar { width:6px; }
#tout::-webkit-scrollbar-thumb { background:var(--ui-line); border-radius:3px; }
#tout .cmd { opacity:.65; }
#tout .err { color:var(--fg); }
#tout a { color:inherit; text-decoration:underline; text-underline-offset:3px; }
#tout .ok::before { content:"✓ "; }
/* Start menu and clickable commands: the terminal can be used entirely without typing */
#tout .tmenu { display:flex; flex-wrap:wrap; gap:6px; margin:.45em 0 .6em; white-space:normal; }
#tout .tmenu button {
  font:inherit; color:var(--ui-ac); background:transparent; cursor:pointer;
  border:1px solid var(--ui-acl); border-radius:3px; padding:4px 10px;
}
#tout .tmenu button:hover, #tout .tmenu button:focus-visible {
  outline:none; border-color:var(--ui-ac); box-shadow:var(--ui-glow), 0 0 0 1px var(--ui-ac) inset;
}
#tout .tcmd {
  font:inherit; color:var(--ui-ac); background:none; border:0; padding:0; margin:0; cursor:pointer;
  text-decoration:underline dotted; text-underline-offset:3px;
}
#tout .tcmd:hover, #tout .tcmd:focus-visible { text-decoration-style:solid; outline:none; }
/* Suggested command: the input line lights up briefly – Enter runs it */
.tline.flash { animation:tflash .9s ease-out; }
@keyframes tflash { 0% { background:var(--ui-acl); } 100% { background:transparent; } }
@media (prefers-reduced-motion: reduce) { .tline.flash { animation:none; } }
#tout .big { font-weight:700; letter-spacing:.15em; color:var(--ui-ac); text-shadow:var(--ui-glow);
             animation:blink 1s steps(1) 3; margin:.3em 0; }
.tline { display:flex; gap:1ch; padding:4px 12px 10px; align-items:baseline; }
#tprompt { white-space:nowrap; opacity:.75; }
#tin {
  flex:1; min-width:0; padding:0; border:0; outline:0; background:transparent;
  font:inherit; color:inherit; caret-color:var(--ui-fg);
}
/* ⏎ button: only on touch devices (computers have Enter) */
#tgo {
  display:none; align-self:center; flex:none; min-width:44px; min-height:36px; margin:-6px -4px -6px 0;
  font:inherit; font-size:18px; line-height:1; color:var(--ui-ac); background:transparent; cursor:pointer;
  border:1px solid var(--ui-acl); border-radius:4px;
}
#tgo:active { background:var(--ui-acl); }
/* iOS zooms into input fields below 16px – so 16px on touch devices */
@media (pointer: coarse) {
  #term { font-size:14px; }
  #tin { font-size:16px; }
  #tprompt { font-size:12px; }
  #tgo { display:block; }
  .tline { align-items:center; }
  #tout .tmenu { gap:8px; }
  #tout .tmenu button { padding:8px 12px; }
  /* Small badges stay visually small, the tap area grows to ≥ 44 px */
  #tbtn, #links a { position:relative; }
  #tbtn::after, #links a::after, #ftab::after { content:''; position:absolute; inset:-10px -8px; }
  #ftab::after { inset:-16px -14px -8px; }
}
/* Image preview for saving (phone): long press -> "Add to Photos" or the share button */
#shot {
  position:fixed; inset:0; z-index:10; display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:12px; padding:var(--st) var(--sr) var(--sb) var(--sl); background:rgba(0,0,0,.86);
  -webkit-backdrop-filter:blur(6px); backdrop-filter:blur(6px);
}
#shot[hidden] { display:none; }
#shotimg {
  max-width:100%; max-height:calc(100% - 120px); object-fit:contain; border:1px solid var(--ui-line);
  box-shadow:0 10px 40px rgba(0,0,0,.6);
  -webkit-touch-callout:default; -webkit-user-select:auto; user-select:auto;   /* allow the long-press menu */
}
#shotinfo { color:#ddd; font:12px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; text-align:center; }
.shotbar { display:flex; flex-wrap:wrap; gap:8px; justify-content:center; }
.shotbar .chip { cursor:pointer; text-decoration:none; margin:0; font-size:13px; padding:7px 12px; }
#shotshare { color:var(--ui-ac); border-color:var(--ui-acl); }
.sr { position:absolute; left:-9999px; }

/* ---------- Clock as a screensaver: no controls, the mouse pointer disappears after a short rest ---------- */
body.zen #foot, body.zen #term, body.zen #ftab { display:none; }
body.zen #art { cursor:default; }
body.zen.idle #art { cursor:none; }

/* ---------- Game mode ---------- */
/* The bottom bar (terminal, privacy) slides out of view – a small tab brings it back */
/* (only move the two badges – the display also lives in #foot and should stay at the top) */
#tbtn, #links { transition:transform .3s ease, opacity .3s ease; }
body.gaming #tbtn, body.gaming #links { transform:translateY(calc(100% + var(--sb) + 8px)); opacity:0; pointer-events:none; }
body.gaming.foot-open #tbtn, body.gaming.foot-open #links { transform:none; opacity:1; pointer-events:auto; }
/* The extended bar as its own area: semi-transparent surface across the full width.
   Deliberately a ::before – backdrop-filter directly on #foot would also capture the display fixed at the top. */
#foot::before {
  content:''; position:absolute; z-index:-1; pointer-events:none;
  left:calc(-1 * var(--sl)); right:calc(-1 * var(--sr)); top:-8px; bottom:calc(-1 * var(--sb));
  background:var(--ui-bg); border-top:1px solid var(--ui-line);
  -webkit-backdrop-filter:blur(6px); backdrop-filter:blur(6px);
  opacity:0; transform:translateY(100%); transition:transform .3s ease, opacity .3s ease;
}
body.gaming.foot-open #foot::before { opacity:1; transform:none; }
#ftab {
  display:none; position:fixed; left:50%; bottom:var(--sb); transform:translateX(-50%);
  padding:1px 14px; font-size:12px; line-height:1.2; cursor:pointer; opacity:.6;
  border-radius:6px 6px 0 0; transition:bottom .3s ease, opacity .2s;
}
#ftab:hover, #ftab:focus-visible { opacity:1; outline:none; }
body.gaming #ftab { display:block; }
/* Mouse pointer over the playfield: only a small dot instead of the crosshair (tab and badges keep their pointer) */
body.gaming #art { cursor:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Ccircle cx='6' cy='6' r='2.5' fill='%23fff' stroke='%23000' stroke-opacity='.6' stroke-width='1.5'/%3E%3C/svg%3E") 6 6, crosshair; }
body.gaming.foot-open #ftab { bottom:calc(var(--sb) + 34px); border-bottom-color:transparent; }   /* the handle sits on the bar */
/* Game display (points, lives …): top centre and larger */
body.gaming #hint {
  position:fixed; top:var(--st); bottom:auto; left:50%; transform:translateX(-50%);
  max-width:calc(100vw - 24px); font-size:15px; padding:6px 14px; opacity:1;
}
@media (max-width: 640px) { body.gaming #hint { font-size:13px; padding:5px 10px; } }
/* High-score board at the end of a game: large, centred below GAME OVER / REKORD! (font size and position are set by gEnd()) */
#hs {
  position:fixed; left:50%; transform:translateX(-50%); z-index:2; pointer-events:none;
  padding:.6em 1.1em .7em; white-space:pre; line-height:1.3;
  font:20px/1.3 ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  color:var(--ui-fg); background:var(--ui-bg); border:1px solid var(--ui-acl); border-radius:6px;
  -webkit-backdrop-filter:blur(6px); backdrop-filter:blur(6px);
  box-shadow:var(--ui-glow), 0 10px 40px rgba(0,0,0,.45);
}
#hs[hidden] { display:none; }
#hs .hd { color:var(--ui-ac); font-weight:700; letter-spacing:.12em; text-align:center; margin-bottom:.6em; text-shadow:var(--ui-glow); }
#hs div:not(.hd):not(.hsbar) { opacity:.72; }
/* Buttons below the board: clickable although the board itself lets clicks through */
#hs .hsbar { display:flex; justify-content:center; gap:.8em; margin-top:.9em; }
#hs .hsbar button {
  pointer-events:auto; cursor:pointer; font:inherit; font-size:.9em; letter-spacing:.06em;
  min-height:44px; padding:.35em 1.1em; border-radius:5px;
  color:var(--ui-fg); background:transparent; border:1px solid var(--ui-line);
}
#hs .hsbar button.go { color:var(--ui-ac); border-color:var(--ui-ac); box-shadow:var(--ui-glow); font-weight:700; }
#hs .hsbar button:hover, #hs .hsbar button:focus-visible { outline:none; background:var(--ui-acl); color:var(--ui-ac); }
#hs .top { opacity:1; }
#hs .me { opacity:1; color:var(--ui-ac); font-weight:700; text-shadow:var(--ui-glow); animation:hsme 1.2s ease-in-out infinite alternate; }
@keyframes hsme { to { opacity:.6; } }
@media (prefers-reduced-motion: reduce) { #hs .me { animation:none; } }
@media (prefers-reduced-motion: reduce) { #tbtn, #links, #ftab, #foot::before { transition:none; } }
