/* ==========================================================================
   David Torossyan — personal site
   One stylesheet for all pages and all three languages. Dark theme only.
   Contrast targets (WCAG AA): text >= 4.5:1, controls/focus >= 3:1.
   ========================================================================== */

:root {
  --bg: #0b0f14;
  --surface: #121a23;
  --surface-2: #192330;
  --border: #2b3746;
  --control: #6f8195;      /* control borders: ~4.6:1 on --bg */
  --text: #e8eef4;         /* ~16:1 on --bg */
  --muted: #a9b6c3;        /* ~8.5:1 on --surface */
  --accent: #5eea9a;       /* ~12:1 on --bg */
  --accent-strong: #8ff5ba;
  --on-accent: #04140b;    /* text on accent buttons */
  --danger: #ff9b9b;       /* ~8:1 on --bg */
  --focus: #ffd166;        /* focus ring, ~12:1 on --bg */

  --radius: 12px;
  --maxw: 1100px;
  --header-h: 64px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  color-scheme: dark;
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(94, 234, 154, 0.07), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
  overflow-wrap: break-word;
}

/* Hide the English placeholder text while a kk/ru dictionary loads
   (class is set by js/i18n.js and always removed within 2 s). */
html.i18n-pending body {
  visibility: hidden;
}

main {
  flex: 1 0 auto;
  outline: none;
}

img,
svg {
  max-width: 100%;
}

img {
  display: block;
  height: auto;
}

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

a:hover {
  color: var(--accent-strong);
}

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

h1,
h2,
h3 {
  line-height: 1.2;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  margin: 0 0 0.5rem;
}

h2 {
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  margin: 2.5rem 0 1rem;
}

h3 {
  font-size: 1.125rem;
  margin: 0 0 0.25rem;
}

p {
  margin: 0 0 1rem;
}

.muted {
  color: var(--muted);
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.offscreen {
  position: fixed;
  top: 0;
  left: -9999px;
  opacity: 0;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -100px;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  border-radius: 8px;
  text-decoration: none;
}

.skip-link:focus {
  top: 0.75rem;
  color: var(--on-accent);
}

.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2rem);
}

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  vertical-align: -0.2em;
}

.icon-sm {
  width: 15px;
  height: 15px;
  vertical-align: -0.1em;
}

/* ---------- Header and navigation ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(11, 15, 20, 0.94);
  border-bottom: 1px solid var(--border);
}

@supports (backdrop-filter: blur(8px)) {
  .site-header {
    background: rgba(11, 15, 20, 0.82);
    backdrop-filter: blur(8px);
  }
}

.header-inner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-right: auto;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.brand:hover {
  color: var(--text);
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.95rem;
}

.site-nav {
  order: 1;
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav a {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}

.site-nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}

.site-nav a[aria-current="page"] {
  color: var(--accent);
  background: var(--surface);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.lang-switch {
  order: 2;
  display: flex;
  gap: 0.2rem;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.lang-switch a {
  display: inline-grid;
  place-items: center;
  min-width: 40px;
  min-height: 36px;
  border-radius: 7px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.875rem;
  text-decoration: none;
}

.lang-switch a:hover {
  color: var(--text);
  background: var(--surface-2);
}

.lang-switch a[aria-current="true"] {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}

.menu-toggle {
  display: none;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0 0.8rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--control);
  border-radius: 10px;
  font: inherit;
  cursor: pointer;
}

.menu-toggle:hover {
  background: var(--surface-2);
}

.menu-toggle[aria-expanded="true"] {
  border-color: var(--accent);
}

/* Menu breakpoint: six nav items in KK/RU need about 1060 px on one row. */
@media (max-width: 1079.98px) {
  .header-inner {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .lang-switch {
    order: 2;
  }

  .js .menu-toggle {
    display: inline-flex;
    order: 3;
  }

  .site-nav {
    order: 4;
    flex-basis: 100%;
  }

  /* Without JavaScript the nav stays visible as a wrapped row. */
  html:not(.js) .site-nav {
    padding-bottom: 0.5rem;
  }

  .js .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    padding: 0.5rem clamp(1rem, 4vw, 2rem) 1rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.45);
  }

  .js .site-nav.is-open {
    display: block;
  }

  .js .site-nav ul {
    flex-direction: column;
  }

  .js .site-nav a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0.6rem 1rem;
  }
}

@media (max-width: 559.98px) {
  .brand-name {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* ---------- Page sections ---------- */

.page-head {
  padding-block: clamp(2rem, 6vw, 3.5rem) 0.5rem;
}

.lead {
  max-width: 65ch;
  color: var(--muted);
  font-size: 1.125rem;
}

.prose,
.prose-page p {
  max-width: 68ch;
}

.list {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

.list li {
  margin-bottom: 0.4rem;
}

.list li::marker {
  color: var(--accent);
}

.more {
  margin-top: 2rem;
}

/* ---------- Home hero ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 2rem;
  align-items: center;
  padding-block: clamp(1.5rem, 4vw, 2.5rem);
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--accent);
  font-weight: 600;
}

.role {
  margin: 0 0 0.75rem;
  font-size: clamp(1.1rem, 2.4vw, 1.35rem);
  font-weight: 600;
}

.hero .lead {
  margin-bottom: 1rem;
}

.chips-label {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1.5rem;
  padding: 0;
  list-style: none;
}

.chips li {
  padding: 0.2rem 0.65rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.875rem;
}

.hero-photo img {
  width: min(100%, 280px);
  aspect-ratio: 1 / 1;
  object-fit: cover;
  margin-inline: auto;
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 0 0 6px rgba(94, 234, 154, 0.08);
}

@media (max-width: 719.98px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .hero-photo {
    order: -1;
  }

  .hero-photo img {
    width: 150px;
    margin-inline: 0;
    border-radius: 20px;
  }
}

/* ---------- Buttons ---------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.6rem 1.1rem;
  border: 1px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

.btn[hidden] {
  display: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn-primary:hover {
  background: var(--accent-strong);
  color: var(--on-accent);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--control);
}

.btn-secondary:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* ---------- Cards and grids ---------- */

.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr));
}

.card {
  min-width: 0;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card h2 {
  margin-top: 0;
}

.card p {
  margin: 0.5rem 0 0;
  color: var(--muted);
}

.card-title {
  margin: 0;
  font-size: 1.2rem;
}

.card-icon {
  width: 28px;
  height: 28px;
  margin-bottom: 0.75rem;
  color: var(--accent);
}

.project {
  display: flex;
  flex-direction: column;
}

.project > p {
  flex: 1 0 auto;
}

.meta {
  display: grid;
  gap: 0.35rem;
  margin: 1rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.95rem;
}

.meta div {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.meta dt {
  color: var(--muted);
}

.meta dt::after {
  content: ":";
}

.meta dd {
  margin: 0;
  min-width: 0;
}

.ext-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  word-break: break-word;
}

.notice {
  margin-top: 2.5rem;
  padding: 1.25rem;
  border: 1px dashed var(--control);
  border-radius: var(--radius);
}

.notice h2 {
  margin-top: 0;
}

.notice p {
  margin: 0;
  color: var(--muted);
}

/* ---------- About timeline ---------- */

.timeline {
  display: grid;
  gap: 1.25rem;
}

.entry {
  padding-left: 1rem;
  border-left: 2px solid var(--border);
}

.entry p,
.entry ul {
  max-width: 68ch;
  margin-bottom: 0;
  color: var(--muted);
}

.entry .entry-meta {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 600;
}

/* ---------- Watches ---------- */

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 200px;
  gap: 2rem;
  align-items: start;
}

.deco-watch {
  width: 180px;
  height: auto;
  margin-top: 3rem;
  color: var(--border);
}

@media (max-width: 719.98px) {
  .split {
    grid-template-columns: 1fr;
  }

  .deco-watch {
    display: none;
  }
}

/* ---------- Contact ---------- */

.contact-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  align-items: start;
}

.email-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.email-address {
  font-size: 1.15rem;
  font-weight: 600;
  word-break: break-all;
}

.link-list {
  display: grid;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.link-list a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 44px;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}

.link-list a:hover {
  background: var(--surface-2);
  color: var(--text);
}

.link-list .icon {
  color: var(--accent);
}

.link-text {
  min-width: 0;
}

.link-handle {
  color: var(--muted);
  word-break: break-all;
}

.form-section {
  margin-top: 1rem;
}

.form {
  display: grid;
  gap: 1.25rem;
  max-width: 640px;
}

.field label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.field input,
.field textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 0.65rem 0.8rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--control);
  border-radius: 8px;
  font: inherit;
}

.field textarea {
  min-height: 9rem;
  resize: vertical;
}

.field input:focus-visible,
.field textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
  border-radius: 8px;
}

.field [aria-invalid="true"] {
  border: 2px solid var(--danger);
}

.field-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 1rem;
}

.hint {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.field-error {
  margin: 0.35rem 0 0;
  color: var(--danger);
  font-size: 0.95rem;
  font-weight: 600;
}

.field-error:empty,
.status:empty {
  display: none;
}

.status {
  margin: 0.75rem 0 0;
  color: var(--text);
}

/* ---------- 404 ---------- */

.notfound {
  padding-block: clamp(3rem, 10vw, 5rem);
  text-align: center;
}

.notfound .lead {
  margin-inline: auto;
}

.code {
  margin: 0 0 0.5rem;
  color: var(--accent);
  font-family: var(--mono);
  font-size: clamp(4rem, 15vw, 7rem);
  font-weight: 700;
  line-height: 1;
}

/* ---------- Footer ---------- */

.site-footer {
  margin-top: 3rem;
  padding-block: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.95rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 2rem;
}

.footer-inner p {
  margin: 0;
}

.social {
  display: flex;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.social a {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
}

.social a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.footer-links a[aria-current="page"] {
  font-weight: 700;
}

/* ---------- Accessibility modes ---------- */

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

@media (forced-colors: active) {
  .lang-switch a[aria-current="true"],
  .site-nav a[aria-current="page"] {
    border: 2px solid CanvasText;
  }

  .btn,
  .card,
  .menu-toggle {
    border: 1px solid CanvasText;
  }
}

/* Retro 88x31 buttons, drawn in CSS (no third-party images) */
.badges { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; padding: 0; width: 100%; }
.badge { display: inline-flex; width: 88px; height: 31px; box-sizing: border-box; border: 1px solid #000; font: 700 9px/1.05 "Courier New", monospace; text-decoration: none; overflow: hidden; }
.badge span { display: flex; align-items: center; justify-content: center; text-align: center; }
.b-512 { background: #ffd23f; color: #111; }
.b-512 span:first-child { width: 44%; background: #c9a227; }
.b-512 span:last-child { width: 56%; }
.b-any, .b-troll { flex-direction: column; justify-content: center; background: #d4d0c8; color: #000; border: 2px outset #fff; }
.b-css { background: #fff; color: #1d5fa8; }
.b-css span:first-child { width: 45%; background: #1d5fa8; color: #fff; font-size: 12px; }
.b-css span:last-child { width: 55%; color: #0a7d2c; }
.b-free { flex-direction: column; justify-content: center; background: #000; color: #39ff14; letter-spacing: .5px; }
.badge:focus-visible { outline: 2px solid var(--accent, #4ade80); outline-offset: 2px; }

.social-nav { display: block; }
.badge-img { display: block; width: 88px; height: 31px; }
