/* ============================================================
   AVINS OS 20.26
   A personal site that boots. System font, because it's a system.
   ============================================================ */

@font-face {
  font-family: 'Martian Mono';
  src: url('fonts/MartianMono-Variable.woff2') format('woff2');
  font-weight: 300 600;
  font-display: swap;
}

:root {
  --desk-a: #23262E;
  --desk-b: #15161A;
  --chrome: rgba(245, 246, 244, 0.88);
  --chrome-solid: #F2F2EF;
  --ink: #1D1F24;
  --dim: #6E7178;
  --line: rgba(29, 31, 36, 0.14);
  --accent: #2E66E5;
  --green: #2FBF56;
  --amber: #F5B62E;
  --red: #E5484D;
  --sys: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
  --mono: 'Martian Mono', ui-monospace, monospace;
  --radius: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45), 0 2px 10px rgba(0, 0, 0, 0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: var(--sys);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(140% 100% at 20% 0%, var(--desk-a), var(--desk-b) 70%);
  overflow: hidden;
}

::selection { background: var(--accent); color: #fff; }

a { color: var(--accent); text-underline-offset: 0.15em; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.mono, .menu-clock, .menu-status, .boot-sub, .desk-credit, .svc-state, .proc, .fine {
  font-family: var(--mono);
}

/* ---------- boot ---------- */

.boot {
  position: fixed; inset: 0; z-index: 90;
  background: #08090B;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1.6rem;
  color: #F5F6F4;
  transition: opacity 0.5s ease, visibility 0.5s;
}
.boot.done { opacity: 0; visibility: hidden; }
.boot-mark { font-size: 2.6rem; font-weight: 700; letter-spacing: 0.1em; }
.boot-bar {
  width: min(280px, 60vw); height: 5px; border-radius: 3px;
  background: rgba(245, 246, 244, 0.18); overflow: hidden;
}
.boot-bar span { display: block; height: 100%; width: 0; background: #F5F6F4; border-radius: 3px; }
.boot-sub { font-size: 0.6rem; letter-spacing: 0.1em; color: #7C8087; text-transform: uppercase; }
html:not(.js) .boot { display: none; }

/* ---------- menu bar ---------- */

.menubar {
  position: fixed; top: 0; left: 0; right: 0; height: 30px;
  display: flex; align-items: stretch;
  background: var(--chrome);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.18);
  z-index: 60;
  padding: 0 10px;
}
.menu-item {
  padding: 0 11px;
  font-size: 13.5px;
  display: flex; align-items: center;
  border-radius: 5px;
}
.menu-logo { font-weight: 700; }
.menu-item:hover, .menu-item.open { background: var(--accent); color: #fff; }
.menu-spacer { flex: 1; }
.menu-status {
  display: flex; align-items: center; gap: 6px;
  font-size: 10px; letter-spacing: 0.08em; color: var(--ink);
}
.menu-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.menu-clock { display: flex; align-items: center; padding-left: 14px; font-size: 11px; }

/* ---------- dropdowns ---------- */

.dropdown {
  position: fixed; top: 32px; z-index: 70;
  min-width: 240px;
  background: var(--chrome);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.35);
  padding: 5px;
}
.dropdown button {
  display: block; width: 100%; text-align: left;
  padding: 5px 10px; border-radius: 5px; font-size: 13.5px;
}
.dropdown button:hover:not(:disabled) { background: var(--accent); color: #fff; }
.dropdown button:disabled { color: rgba(29, 31, 36, 0.4); cursor: default; }
.dropdown hr { border: 0; border-top: 1px solid var(--line); margin: 5px 8px; }

/* ---------- desktop & icons ---------- */

.desktop { position: fixed; inset: 30px 0 0 0; }

.icons {
  position: absolute; top: 22px; right: 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.icon {
  width: 96px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 8px 4px; border-radius: 8px;
}
.icon:hover { background: rgba(245, 246, 244, 0.09); }
.icon-art { font-size: 30px; filter: grayscale(0.15); }
.icon-label {
  font-size: 11.5px; color: #F5F6F4; text-align: center; line-height: 1.25;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* ---------- windows ---------- */

.window {
  position: absolute;
  left: var(--x, 10vw); top: var(--y, 12vh);
  width: var(--w, 600px);
  max-width: calc(100vw - 24px);
  background: var(--chrome-solid);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(0, 0, 0, 0.2);
  overflow: hidden;
}
.window.focused { box-shadow: 0 26px 70px rgba(0, 0, 0, 0.55), 0 3px 12px rgba(0, 0, 0, 0.35); }

.w-bar {
  display: flex; align-items: center;
  height: 36px;
  padding: 0 12px;
  background: linear-gradient(#FAFAF8, #EFEFEB);
  border-bottom: 1px solid var(--line);
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.w-bar:active { cursor: grabbing; }
.lights { display: flex; gap: 7px; margin-right: 12px; }
.light {
  width: 12px; height: 12px; border-radius: 50%;
  border: 0.5px solid rgba(0, 0, 0, 0.2);
  padding: 0; display: block;
}
.light.close { background: var(--red); cursor: pointer; }
.light.min { background: var(--amber); opacity: 0.5; }
.light.max { background: var(--green); opacity: 0.5; }
.w-title { font-size: 13px; font-weight: 600; color: var(--dim); flex: 1; text-align: center; margin-right: 60px; }

.w-body { padding: 18px 20px 22px; max-height: min(58vh, 520px); overflow: auto; }

/* about */
.about-body { display: grid; grid-template-columns: 200px 1fr; gap: 18px; }
.about-photo { width: 100%; height: auto; border-radius: 6px; filter: grayscale(1); }
.about-text h3 { font-size: 19px; margin-bottom: 2px; }
.about-text .sub { color: var(--dim); margin-bottom: 12px; font-size: 13px; }
.about-text p { margin-bottom: 10px; }
.fine { color: var(--dim); font-size: 10px; letter-spacing: 0.04em; margin-top: 6px; }
@media (max-width: 560px) { .about-body { grid-template-columns: 1fr; } }

/* metrics */
.meters { list-style: none; display: flex; flex-direction: column; gap: 16px; }
.meter-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.meter-head span { font-size: 13px; color: var(--dim); }
.meter-head strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.meter { height: 8px; border-radius: 4px; background: rgba(29, 31, 36, 0.1); overflow: hidden; }
.meter-fill {
  display: block; height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), #6D9BFF);
  width: 0;
  transition: width 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.meter-fill.zero { background: var(--green); min-width: 3px; }
.win-open .meter-fill { width: var(--v); }

/* capabilities */
.svc { list-style: none; display: flex; flex-direction: column; }
.svc li {
  display: grid; grid-template-columns: 14px 1fr auto; gap: 12px; align-items: start;
  padding: 12px 2px; border-bottom: 1px solid var(--line);
}
.svc li:last-child { border-bottom: 0; }
.svc-status { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; }
.svc-status.on { background: var(--green); box-shadow: 0 0 6px rgba(47, 191, 86, 0.5); }
.svc h3 { font-size: 14.5px; }
.svc p { font-size: 13px; color: var(--dim); }
.svc-state { font-size: 9.5px; color: var(--green); letter-spacing: 0.06em; margin-top: 5px; }

/* processes */
.proc { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.proc th {
  text-align: left; font-weight: 500; color: var(--dim);
  border-bottom: 1px solid var(--line); padding: 4px 10px 6px 0;
  font-size: 9.5px; letter-spacing: 0.07em; text-transform: uppercase;
}
.proc td { padding: 9px 10px 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.proc td:nth-child(2) { font-weight: 600; white-space: nowrap; }
.proc td:last-child { font-variant-numeric: tabular-nums; }
.proc tr.dim td { color: var(--dim); border-bottom: 0; }

/* contact */
.contact-body { text-align: left; }
.contact-big { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 6px; }
.contact-body > p { margin-bottom: 14px; color: var(--dim); }
.btn-primary {
  display: inline-block;
  background: var(--accent); color: #fff;
  padding: 9px 16px; border-radius: 8px;
  font-weight: 600; font-size: 14px;
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.btn-primary:hover { filter: brightness(1.08); color: #fff; }
.contact-row { display: flex; gap: 18px; margin-top: 16px; font-size: 13.5px; }

/* readme + dialog */
.readme { font-size: 16px; line-height: 1.7; }
.dialog-body { display: grid; grid-template-columns: 44px 1fr; gap: 14px; align-items: start; }
.dialog-icon { font-size: 34px; }
.dialog-body p { margin-bottom: 8px; font-size: 13.5px; }
.dialog-body .btn-primary { margin-top: 4px; border: 0; cursor: pointer; }

/* ---------- longbow ---------- */

.game-main { position: relative; }
.game-rotate[hidden] { display: none; }
.game-rotate {
  position: absolute; inset: 0; z-index: 5;
  background: var(--chrome-solid);
  display: grid; place-content: center; text-align: center;
  gap: 6px;
}
.rot-icon { font-size: 40px; animation: rot-hint 2.2s ease-in-out infinite; }
@keyframes rot-hint {
  0%, 55%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(90deg); }
}
.rot-big { font-family: var(--mono); font-size: 13px; letter-spacing: 0.12em; font-weight: 600; }
.rot-sub { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.08em; color: var(--dim); }

/* landscape phone: the game owns the screen */
html.game-fs .menubar,
html.game-fs .icons,
html.game-fs .dock,
html.game-fs .home-indicator,
html.game-fs .desk-credit { display: none; }
html.game-fs .desktop { inset: 0; }
html.game-fs #w-game {
  position: fixed !important;
  inset: 0 !important;
  left: 0 !important; top: 0 !important;
  width: 100% !important; height: 100%;
  max-width: none;
  border-radius: 0; border: 0;
  resize: none;
  display: flex; flex-direction: column;
}
html.game-fs #w-game .w-bar { height: 34px; flex: none; }
html.game-fs #w-game .w-body { flex: 1; max-height: none; padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px)); }
html.game-fs .game-body { grid-template-columns: 1fr; gap: 0; max-height: none; height: 100%; }
html.game-fs .game-board { display: none; }
html.game-fs .game-main { display: flex; flex-direction: column; height: 100%; }
html.game-fs #gameCanvas { aspect-ratio: auto; flex: 1 1 0; min-height: 0; width: 100%; height: 0; }
html.game-fs .game-hud { margin-top: 6px; }
html.game-fs .game-hint { margin-top: 4px; }

#w-game { resize: horizontal; overflow: hidden; min-width: 560px; max-width: 96vw; }
#w-game .w-body { max-height: none; }

.game-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 18px;
  max-height: min(66vh, 620px);
}
.game-main { min-width: 0; }
#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 1;
  background: linear-gradient(#FDFDFC, #F7F7F5);
  border-radius: 6px;
  border: 1px solid var(--line);
  cursor: crosshair;
  touch-action: none;
}
.game-hud {
  display: flex; flex-wrap: wrap; gap: 4px 16px;
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--dim);
}
.game-hud #ghBest { color: var(--accent); }
.game-hint {
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--dim);
}
.game-claim[hidden] { display: none; }
.game-claim {
  display: flex; align-items: center; gap: 8px;
  margin-top: 12px; flex-wrap: wrap;
}
.game-claim label { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.06em; color: var(--accent); }
.game-claim input {
  width: 64px;
  font-family: var(--mono);
  font-size: 15px;
  text-transform: uppercase;
  text-align: center;
  padding: 5px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
.game-claim .btn-primary { padding: 6px 12px; font-size: 13px; border: 0; cursor: pointer; }

.game-board { border-left: 1px solid var(--line); padding-left: 16px; min-width: 0; }
.game-board h3 {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  color: var(--dim);
  margin-bottom: 10px;
}
.game-board ol { list-style: none; display: flex; flex-direction: column; gap: 5px; }
.game-board li {
  display: flex; justify-content: space-between; gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 0;
  border-bottom: 1px dashed var(--line);
}
.game-board li .b-name { color: var(--ink); }
.game-board li .b-dist { color: var(--accent); font-variant-numeric: tabular-nums; }
.game-board li.you .b-name, .game-board li.you .b-dist { color: var(--green); font-weight: 600; }
.game-board .board-empty { color: var(--dim); border: 0; font-size: 10px; }
.game-board .fine { margin-top: 12px; font-size: 8.5px; line-height: 1.5; }

/* ---------- dock ---------- */

.dock {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px;
  padding: 7px 10px;
  background: rgba(245, 246, 244, 0.22);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(245, 246, 244, 0.28);
  border-radius: 18px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.4);
}
.dock-item {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  font-size: 27px;
  border-radius: 12px;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}
.dock-item:hover { transform: translateY(-8px) scale(1.18); }
.dock-item.running::after {
  content: ''; position: absolute; bottom: -5px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%; background: #F5F6F4;
}
.dock-sep { width: 1px; height: 34px; background: rgba(245, 246, 244, 0.3); margin: 0 3px; }

.desk-credit {
  position: absolute; bottom: 14px; left: 16px;
  font-size: 9px; letter-spacing: 0.08em;
  color: rgba(245, 246, 244, 0.4);
}
@media (max-width: 900px) { .desk-credit { display: none; } }

/* ---------- toast ---------- */

.toast {
  position: fixed; top: 44px; left: 50%; transform: translateX(-50%) translateY(-8px);
  background: var(--chrome-solid); color: var(--ink);
  padding: 8px 16px; border-radius: 8px;
  font-size: 13px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 80;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- chaos mode ---------- */

@keyframes wobble {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-1.2deg); }
  75% { transform: rotate(1.4deg); }
}
.chaos-mode .window { animation: wobble 0.35s ease-in-out infinite; }

/* ---------- window open/close animation ---------- */

.window { transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.34, 1.4, 0.64, 1); }
.window.opening { opacity: 0; transform: scale(0.92) translateY(10px); }

/* ---------- home indicator (phone only) ---------- */

.home-indicator { display: none; }

/* ---------- phone OS ---------- */

@media (max-width: 700px) {
  body { overflow-y: auto; }
  body::after { content: ''; display: block; height: 18vh; }

  /* status bar */
  .menubar { height: 34px; padding: 0 16px; align-items: center; }
  .menu-item:not(.menu-logo) { display: none; }
  .menu-logo { font-size: 14px; padding: 0; pointer-events: none; }
  .menu-clock { font-size: 12px; font-weight: 600; }
  .desktop { inset: 34px 0 0 0; }

  /* home screen: springboard grid */
  .icons {
    position: static;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px 6px;
    padding: 34px 18px 0;
  }
  .icon { width: auto; padding: 0; gap: 7px; }
  .icon:hover { background: none; }
  .icon-art {
    display: grid; place-items: center;
    width: 58px; height: 58px;
    font-size: 30px;
    background: rgba(245, 246, 244, 0.94);
    border-radius: 14px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  }
  .icon-label { font-size: 11px; }

  /* apps: one at a time, full screen sheets */
  .window[hidden] { display: none; }
  .window {
    position: fixed;
    inset: 34px 0 0 0 !important;
    left: 0 !important; top: 34px !important;
    width: 100% !important; max-width: none;
    height: calc(100% - 34px);
    border-radius: 16px 16px 0 0;
    border: 0;
    display: flex; flex-direction: column;
  }
  .window.opening { transform: translateY(6%); opacity: 0; }
  .w-bar { cursor: default; height: 44px; flex: none; }
  .light.min, .light.max { display: none; }
  .light.close {
    width: auto; height: auto;
    background: none; border: 0;
    font-size: 15px; font-weight: 500; color: var(--accent);
    border-radius: 6px;
  }
  .light.close::before { content: '‹ Home'; }
  .w-title { margin-right: 64px; }
  .w-body { max-height: none; flex: 1; padding-bottom: 40px; }

  /* dock: sits above the home indicator */
  .dock { bottom: calc(18px + env(safe-area-inset-bottom, 0px)); gap: 4px; padding: 8px 12px; }
  .dock-item { width: 52px; height: 52px; font-size: 30px; }
  .dock-item:hover { transform: none; }
  .dock-sep { display: none; }
  .dock-item.trash { display: none; }

  .home-indicator {
    display: block;
    position: fixed;
    bottom: calc(5px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%);
    width: 120px; height: 5px;
    border-radius: 3px;
    background: rgba(245, 246, 244, 0.55);
    z-index: 58;
    padding: 0;
  }

  #w-game { resize: none; min-width: 0; }
  .game-body { grid-template-columns: 1fr; }
  .game-board { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 12px; }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .boot { display: none; }
  .window, .dock-item, .meter-fill, .toast { transition: none; animation: none; }
  .chaos-mode .window { animation: none; }
  .win-open .meter-fill { width: var(--v); }
}
