/* ==========================================================================
   Tomer Berger — portfolio
   No imports, no web fonts, no external requests.

   Contrast, computed against the WCAG 2.1 relative-luminance formula.
   Body text needs 4.5:1; large text and functional UI boundaries need 3:1.

     #e6edf3 text     on #0d1117 bg ....... 16.02:1   AA / AAA
     #e6edf3 text     on #161b22 surface .. 14.64:1   AA / AAA
     #8b949e muted    on #0d1117 bg .......  6.15:1   AA
     #8b949e muted    on #161b22 surface ..  5.62:1   AA
     #79c0ff accent   on #0d1117 bg .......  9.73:1   AA / AAA
     #79c0ff accent   on #161b22 surface ..  8.89:1   AA / AAA
     #a5d6ff code     on #161b22 surface .. 11.25:1   AA / AAA
     #7ee787 tag      on #0d1117 bg ....... 12.32:1   AA / AAA
     #6e7681 border-s on #0d1117 bg .......  4.12:1   AA (non-text 3:1)
     #6e7681 border-s on #161b22 surface ..  3.77:1   AA (non-text 3:1)

   --border (#30363d) is 1.55:1 and is DECORATIVE only: it never carries
   meaning on its own. Every element that uses it is already separated from
   the page by its own --surface fill, so the border is a refinement, not
   the thing that makes the element perceivable. Anything a user has to
   see to operate — buttons, the focus ring, the nav toggle — uses
   --border-strong instead.
   ========================================================================== */

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1c2230;
  --border: #30363d;         /* decorative only — see note above */
  --border-strong: #6e7681;  /* functional boundaries, >= 3:1 */
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #79c0ff;
  --accent-quiet: #1f6feb;
  --code: #a5d6ff;
  --tag: #7ee787;

  --measure: 68ch;
  --gutter: clamp(1.25rem, 5vw, 2.5rem);

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

/* ---------- reset ---------- */

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

html {
  scroll-behavior: smooth;
  /* header height + breathing room, so anchors don't land under the bar */
  scroll-padding-top: 5rem;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  line-height: 1.65;
  /* long unbreakable tokens (emails, X-Content-Type-Options) must not
     push the page sideways at 360px */
  overflow-wrap: break-word;
}

h1, h2, h3, h4 {
  line-height: 1.2;
  margin: 0 0 0.5em;
  font-weight: 650;
  letter-spacing: -0.015em;
}

p { margin: 0 0 1.1em; }
ul, dl { margin: 0; padding: 0; }
li { list-style: none; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--text); }

code {
  font-family: var(--mono);
  font-size: 0.875em;
  color: var(--code);
  background: var(--surface);
  border-radius: 4px;
  padding: 0.12em 0.36em;
  /* a long path should wrap rather than widen the page */
  overflow-wrap: anywhere;
}

strong { color: var(--text); font-weight: 650; }

/* ---------- utilities ---------- */

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

.wrap {
  width: 100%;
  max-width: 60rem;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.skip-link {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translate(-50%, -120%);
  z-index: 100;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 0 0 8px 8px;
  padding: 0.6rem 1.1rem;
  text-decoration: none;
}
.skip-link:focus-visible { transform: translate(-50%, 0); }

/* Focus is never removed — only restyled. 2px accent ring, always visible
   against both --bg and --surface. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ---------- header / nav ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.5rem;
}

.wordmark {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.06em;
  color: var(--text);
  text-decoration: none;
  padding: 0.35rem 0.5rem;
  margin-left: -0.5rem;
  border-radius: 6px;
}
.wordmark:hover { color: var(--accent); }

.site-nav ul {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.site-nav a {
  display: block;
  padding: 0.45rem 0.7rem;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9375rem;
  transition: color 0.12s ease, background-color 0.12s ease;
}
.site-nav a:hover { color: var(--text); background: var(--surface); }

/* set by main.js; falls back to plain links when JS is off */
.site-nav a[aria-current="true"] {
  color: var(--text);
  background: var(--surface);
}

.nav-toggle { display: none; }

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

section { padding-block: clamp(3rem, 8vw, 5.5rem); }

section + section { border-top: 1px solid var(--border); }

h2 {
  font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2rem);
  margin-bottom: 1.2rem;
}

section > .wrap > p,
section > .wrap > dl { max-width: var(--measure); }

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

.hero { padding-block: clamp(3.5rem, 11vw, 7rem); }

.hero h1 {
  font-size: clamp(2.25rem, 1.6rem + 3.2vw, 3.75rem);
  margin-bottom: 0.25em;
}

.tagline {
  font-size: clamp(1.125rem, 1rem + 0.7vw, 1.5rem);
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 0.9em;
}

.lede {
  font-size: clamp(1.0625rem, 1rem + 0.3vw, 1.1875rem);
  color: var(--text);
  max-width: var(--measure);
}

.availability {
  color: var(--muted);
  font-size: 0.9375rem;
  margin-bottom: 1.8em;
}

.hero-links,
.project-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-block;
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 550;
  text-decoration: none;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.btn:hover {
  background: var(--surface-2);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #05131f; /* 13.9:1 on #79c0ff */
}
.btn-primary:hover {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

/* ---------- projects ---------- */

.project {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: clamp(1.25rem, 4vw, 2rem);
  max-width: var(--measure);
}
.project + .project { margin-top: 1.75rem; }

.project-head { margin-bottom: 1.1rem; }

.project h3 {
  font-size: clamp(1.25rem, 1.1rem + 0.7vw, 1.5rem);
  margin-bottom: 0.15em;
}

.project-sub {
  color: var(--muted);
  font-size: 0.9375rem;
  margin: 0;
}

.project h4 {
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 650;
  margin: 1.6em 0 0.6em;
}

.stack { color: var(--text); }

.decisions li {
  position: relative;
  padding-left: 1.1rem;
  margin-bottom: 0.85em;
}
.decisions li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}
.decisions li:last-child { margin-bottom: 0; }

.project-links { margin-top: 1.6rem; }

.status {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.65rem;
  margin: 1.6rem 0 0;
  padding: 0.85rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--tag);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.9375rem;
}

.status-tag {
  flex: none;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--tag);
  font-weight: 700;
}

/* ---------- security cards ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
  margin: 1.75rem 0 0;
}

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

.card h3 {
  font-size: 1.0625rem;
  margin-bottom: 0.5em;
}

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

.callout {
  margin: 1.75rem 0 0;
  padding-left: 1rem;
  border-left: 3px solid var(--accent-quiet);
  color: var(--muted);
  max-width: var(--measure);
}

/* ---------- skills ---------- */

.skills {
  display: grid;
  grid-template-columns: minmax(9rem, 14rem) 1fr;
  gap: 0.4rem 2rem;
  align-items: baseline;
}

.skills dt {
  font-weight: 650;
  color: var(--text);
  font-size: 0.9375rem;
  padding-top: 0.55rem;
}

.skills dd {
  margin: 0;
  color: var(--muted);
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.skills dd:last-of-type { border-bottom: 0; }

/* ---------- contact ---------- */

.contact-list {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
  max-width: var(--measure);
}

.contact-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 1rem;
}

.contact-label {
  flex: none;
  min-width: 5.5rem;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 650;
}

.contact-value {
  font-family: var(--mono);
  font-size: 0.9375rem;
  overflow-wrap: anywhere;
}

.note {
  color: var(--muted);
  font-size: 0.9375rem;
  max-width: var(--measure);
}

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding-block: 2.5rem 3rem;
  color: var(--muted);
  font-size: 0.9375rem;
}
.site-footer p { margin: 0 0 0.35em; }
.site-footer .note { font-size: 0.875rem; }

/* ==========================================================================
   Small screens. Verified at 360px, 390px and 768px.
   ========================================================================== */

@media (max-width: 40rem) {

  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
  }

  .nav-toggle-bars,
  .nav-toggle-bars::before,
  .nav-toggle-bars::after {
    display: block;
    width: 1rem;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
  }
  .nav-toggle-bars { position: relative; }
  .nav-toggle-bars::before,
  .nav-toggle-bars::after { content: ""; position: absolute; left: 0; }
  .nav-toggle-bars::before { top: -5px; }
  .nav-toggle-bars::after { top: 5px; }

  .site-nav {
    display: none;
    width: 100%;
    order: 3;
    padding-bottom: 0.75rem;
  }
  .site-nav.open { display: block; }

  .site-nav ul {
    flex-direction: column;
    gap: 0.15rem;
  }
  .site-nav a { padding: 0.6rem 0.7rem; }

  .header-inner { flex-wrap: wrap; }

  .hero-links .btn,
  .project-links .btn { flex: 1 1 auto; text-align: center; }

  /* Two columns is unreadable under ~40rem — stack the term over the value */
  .skills { grid-template-columns: 1fr; gap: 0; }
  .skills dt { padding-top: 1rem; }
  .skills dd { padding-top: 0.15rem; }

  .contact-label { min-width: 0; width: 100%; }
}

/* No-JS safety net: if main.js never runs, the toggle is meaningless, so
   the nav must stay visible rather than being permanently hidden. */
@media (max-width: 40rem) {
  html:not(.js) .site-nav { display: block; }
  html:not(.js) .nav-toggle { display: none; }
}

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- print ---------- */

@media print {
  .site-header, .skip-link, .nav-toggle { display: none; }
  body { background: #fff; color: #000; }
  .project, .card { border-color: #999; break-inside: avoid; }
  a { color: #000; }
}
