/*
  Main stylesheet for vojtechhavranek.cz
  - High contrast, system fonts, light/dark themes
  - Playful but subtle animations and micro‑interactions
  - Pure CSS, with prefers-reduced-motion respected
*/

:root {
  --bg: #0b0c0f;
  --fg: #e8eaed;
  --muted: #b2b7bd;
  /* Chrome (neutral) accent in base to avoid blue */
  --accent: #4b5563; /* slate-600 like — good contrast with white */
  --card: #121419;
  --border: #23272f;
  --link: #cbd5e1; /* light slate for dark background links */

  /* Softer, more modern radii and shadows */
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-1: 0 1px 0 rgba(0,0,0,.08);
  --shadow-2: 0 12px 28px rgba(0,0,0,.20);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff;
    --fg: #111418;
    --muted: #4c5561;
    /* Chrome/neutral accent for light mode */
    --accent: #374151; /* gray-700 like */
    --card: #f7f9fc;
    --border: #e3e8ef;
    --link: #475569; /* slate-600 like */
  }
}

/* Explicit theme overrides via [data-theme] always win over system preference */
:root[data-theme="dark"] {
  --bg: #0b0c0f;
  --fg: #e8eaed;
  --muted: #b2b7bd;
  --accent: #4b5563; /* chrome-ish neutral */
  --card: #121419;
  --border: #23272f;
  --link: #cbd5e1;

  /* Subtle dark chrome tokens */
  --chrome-top: color-mix(in oklab, #ffffff 4%, var(--card));
  --chrome-bottom: color-mix(in oklab, #000000 8%, var(--card));
  --chrome-edge: color-mix(in oklab, var(--accent) 16%, var(--border));
  --chrome-sheen: color-mix(in oklab, #ffffff 10%, transparent);
}

:root[data-theme="light"] {
  --bg: #ffffff;
  --fg: #111418;
  --muted: #4c5561;
  --accent: #374151; /* chrome-ish neutral for light */
  --card: #f7f9fc;
  --border: #e3e8ef;
  --link: #475569;
}

/* Base and layout */
html { box-sizing: border-box; }
*, *::before, *::after { box-sizing: inherit; }
html, body { height: 100%; }

/* Smooth scrolling but opt-out for reduced motion */
:root { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  :root { scroll-behavior: auto; }
}

body {
  margin: 0;
  font-family: "Elms Sans", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Offset for fixed header so content isn't hidden underneath */
  padding-top: 80px;
}

a { color: var(--link); text-decoration: none; }
/* Playful underline reveal */
a:not(.btn) {
  background: linear-gradient(currentColor, currentColor) 0% 100% / 0 2px no-repeat;
  transition: background-size .25s ease, color .2s ease;
}
a:not(.btn):hover { background-size: 100% 2px; }

a:focus, button:focus, [tabindex]:focus {
  outline: 3px solid color-mix(in oklab, var(--accent) 60%, white);
  outline-offset: 3px; border-radius: 4px;
}

.skip-link {
  position: absolute; left: -999px; top: auto; width: 1px; height: 1px; overflow: hidden;
}
.skip-link:focus {
  left: 16px; top: 16px; width: auto; height: auto; padding: .5rem .75rem;
  background: var(--card); color: var(--fg); border: 2px solid var(--accent);
  border-radius: var(--radius-sm); z-index: 1000;
}

/* Header: fixed with subtle blur and gradient border (keeps menu always visible) */
header[role="banner"] {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  padding: 1.25rem 1rem 1rem;
  background: color-mix(in oklab, var(--bg) 85%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid color-mix(in oklab, var(--border) 70%, transparent);
}

/* Subtle chrome gloss for header in dark mode */
:root[data-theme="dark"] header[role="banner"] {
  background: linear-gradient(180deg, color-mix(in oklab, var(--bg) 92%, transparent), color-mix(in oklab, var(--bg) 80%, transparent));
  border-bottom: 1px solid var(--chrome-edge);
}

/* Theme segmented radio control (in-header, not fixed) */
.theme-switch {
  position: static; z-index: 1;
  display: inline-flex; align-items: center; gap: 2px;
  padding: 2px;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--border) 70%, transparent);
  background: color-mix(in oklab, var(--card) 85%, var(--bg));
  box-shadow: 0 4px 12px rgba(0,0,0,.18);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: .7; /* slightly less prominent */
  transition: opacity .2s ease;
  margin-left: auto; /* push to the far right in header flex */
}

/* Chrome pill effect in dark theme */
:root[data-theme="dark"] .theme-switch {
  background: linear-gradient(180deg, var(--chrome-top), var(--chrome-bottom));
  border-color: var(--chrome-edge);
}

.theme-switch:hover,
.theme-switch:focus-within { opacity: 1; }

.theme-switch input[type="radio"] {
  position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%);
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px; /* Visually hidden but accessible */
}

.theme-switch .seg {
  position: relative;
  padding: .35rem .55rem; /* slightly smaller visual footprint */
  border-radius: 999px;
  font-weight: 600; font-size: .78rem; letter-spacing: .2px;
  color: var(--muted);
  cursor: pointer; user-select: none;
  transition: color .2s ease, background-color .2s ease, box-shadow .2s ease, transform .16s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 0;
  min-width: 40px; /* still finger-friendly on mobile */
}

.theme-switch .seg:hover { transform: translateY(-0.5px); }
.theme-switch .seg:active { transform: translateY(0); }

/* Active state when the preceding radio is checked */
#theme-dark:checked + label[for="theme-dark"],
#theme-light:checked + label[for="theme-light"] {
  color: var(--fg);
  background: var(--card);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--accent) 35%, var(--border)), 0 2px 8px rgba(0,0,0,.14);
}

/* Active segment gets a soft sheen in dark theme */
:root[data-theme="dark"] #theme-dark:checked + label[for="theme-dark"],
:root[data-theme="dark"] #theme-light:checked + label[for="theme-light"] {
  background: linear-gradient(180deg, color-mix(in oklab, var(--card) 88%, var(--chrome-sheen)), var(--card));
}

/* Focus ring when tabbing onto the radio */
#theme-dark:focus-visible + label[for="theme-dark"],
#theme-light:focus-visible + label[for="theme-light"] {
  outline: 3px solid color-mix(in oklab, var(--accent) 60%, white);
  outline-offset: 2px;
}

/* Icons and text within segmented labels */
.theme-switch .seg .ic { font-size: .95rem; line-height: 1; display: inline-block; }
/* Smooth icon state changes */
.theme-switch .seg .ic { transition: filter .2s ease, opacity .2s ease; }
/* Keep label text accessible for screen readers but hide it visually — icons only */
.theme-switch .seg .txt {
  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;
}

/* Inactive option appears grayed out */
#theme-dark:not(:checked) + label[for="theme-dark"],
#theme-light:not(:checked) + label[for="theme-light"] {
  color: var(--muted);
  opacity: .78;
}

/* Make the inactive icon black-and-white (grayscale) */
#theme-dark:not(:checked) + label[for="theme-dark"] .ic,
#theme-light:not(:checked) + label[for="theme-light"] .ic {
  filter: grayscale(1) contrast(.95);
}

/* Ensure active icon is full color (no filter) */
#theme-dark:checked + label[for="theme-dark"] .ic,
#theme-light:checked + label[for="theme-light"] .ic {
  filter: none;
}

@media (prefers-reduced-motion: reduce) {
  .theme-switch .seg { transition: none; }
}

.container { max-width: 1040px; margin: 0 auto; padding: 0 1.25rem; }
/* Header layout to keep nav and theme switch from overlapping */
.header-spacer {}
.header-sticky {}
.header-shadow {}
.header-bg {}
header[role="banner"] {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
header[role="banner"] nav { display: flex; align-items: center; gap: 1rem; }

/* Mobile menu toggle (hidden on desktop) */
.menu-toggle { display: none; margin-left: .25rem; }
.menu-toggle {
  appearance: none; border: 1px solid var(--border); background: var(--card); color: var(--fg);
  padding: .4rem; line-height: 1; cursor: pointer; border-radius: 0; box-shadow: var(--shadow-1);
  /* display is controlled by media query; hidden on desktop, shown on mobile */
  align-items: center; justify-content: center; gap: .5rem;
}
.menu-toggle .mtxt {
  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;
}
.menu-toggle .icon-burger, .menu-toggle .icon-close { font-size: 1.05rem; }
.menu-toggle .icon-close { display: none; }
body.menu-open .menu-toggle .icon-burger { display: none; }
body.menu-open .menu-toggle .icon-close { display: inline; }

/* Mobile nav panel */
@media (max-width: 768px) {
  header[role="banner"] nav { display: none; }
  .menu-toggle { display: inline-flex; margin-left: auto; }
  /* When menu is open, show a simple overlay panel with the links */
  body.menu-open header[role="banner"] nav {
    display: grid;
    position: fixed; top: 80px; left: 0; right: 0; z-index: 90; /* top overridden inline via JS for dynamic header height */
    background: color-mix(in oklab, var(--bg) 96%, transparent);
    border-bottom: 1px solid var(--border);
    padding: .25rem 0 .5rem;
  }
  body.menu-open header[role="banner"] nav a {
    display: block; padding: .9rem 1rem; border-top: 1px solid color-mix(in oklab, var(--border) 80%, transparent);
  }
  /* Keep header items compact */
  .theme-switch { margin-left: 0; }
}

/* Prevent background scroll when mobile menu is open */
@media (max-width: 768px) {
  body.menu-open { overflow: hidden; }
}

/* Brand link in header (name links to top) */
.brand { color: var(--fg); text-decoration: none; }
.brand:hover { text-decoration: underline; }

@media (max-width: 700px) {
  .theme-switch { margin-left: 0; }
}

.hero { display: grid; gap: 1.5rem; align-items: center; grid-template-columns: auto 1fr; }
.portrait { display: flex; align-items: center; justify-content: center; }
.avatar {
  width: 144px; height: 144px; border-radius: 50%;
  border: 2px solid color-mix(in oklab, var(--accent) 40%, var(--border));
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  object-fit: cover; background: var(--card);
}

/* Metallic ring nuance in dark mode */
:root[data-theme="dark"] .avatar {
  box-shadow: 0 8px 24px rgba(0,0,0,.25), inset 0 0 0 1px color-mix(in oklab, #ffffff 6%, transparent);
}
.hero-text { min-width: 0; }
.hero h1 {
  font-size: clamp(2rem, 3.2vw + 1rem, 3rem); line-height: 1.15; margin: 0;
  letter-spacing: .2px;
  /* gentle entrance */
  animation: fadeSlideUp .7s ease both .05s;
}
.hero p.role { margin: 0; color: var(--muted); font-size: 1.1rem; animation: fadeSlideUp .7s ease both .15s; }
.actions { margin-top: 1rem; display: flex; gap: 1rem; flex-wrap: wrap; animation: fadeSlideUp .7s ease both .25s; }

.btn {
  display: inline-block; padding: .7rem 1.05rem; border-radius: 0;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg); text-decoration: none; font-weight: 600; box-shadow: var(--shadow-1);
  transform: translateZ(0);
  transition: transform .18s ease, box-shadow .18s ease, background .25s ease, border-color .25s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.btn:active { transform: translateY(0); }
.btn.primary {
  border-color: color-mix(in oklab, var(--accent), var(--border));
  background: var(--accent);
  color: #fff;
}
.btn.primary:hover { box-shadow: 0 8px 24px color-mix(in oklab, var(--accent) 45%, black); }

/* Chrome button treatments in dark theme */
:root[data-theme="dark"] .btn {
  background: linear-gradient(180deg, var(--chrome-top), var(--chrome-bottom));
  border-color: var(--chrome-edge);
}
:root[data-theme="dark"] .btn.primary {
  background: linear-gradient(180deg, color-mix(in oklab, var(--accent) 92%, #ffffff 0%), color-mix(in oklab, var(--accent) 86%, #000 0%));
  border-color: color-mix(in oklab, var(--accent) 70%, var(--border));
}

/* Main and sections */
main { padding: 1.5rem 0 4rem; }
section {
  margin: 2.5rem 0; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem; position: relative;
  transition: border-color .25s ease, transform .2s ease;
  animation: fadeSlideUp .6s ease both;
}
section:hover { border-color: color-mix(in oklab, var(--accent) 30%, var(--border)); transform: translateY(-2px); }
section h2 { margin-top: 0; font-size: 1.4rem; letter-spacing: .2px; }
.summary { font-size: 1.05rem; color: var(--fg); }
.muted { color: var(--muted); }

/* Anchor offset so sticky header doesn't cover targets */
:where(section[id], h2[id]) { scroll-margin-top: 80px; }

/* Card chrome surface for dark mode */
:root[data-theme="dark"] section,
:root[data-theme="dark"] .projects .card {
  background: linear-gradient(180deg, var(--chrome-top), var(--chrome-bottom));
  border-color: var(--chrome-edge);
}

.experience .item { padding: 1rem 0; border-top: 1px solid var(--border); }
.experience .item:first-child { border-top: 0; }
.experience .meta { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: baseline; }
.experience .role { font-weight: 700; }
.experience .company { color: var(--muted); }
.experience .dates { color: var(--muted); font-variant-numeric: tabular-nums; }
.experience .description { margin: .75rem 0 .25rem; color: var(--fg); }
/* Collapsible experience details */
.experience details { margin-top: .25rem; }
.experience summary {
  cursor: pointer;
  color: var(--link);
  font-weight: 600;
}
.experience summary:hover { text-decoration: underline; }
.experience details[open] summary { color: var(--fg); }
.experience details ul { margin-top: .5rem; }

.projects .cards {
  display: grid; gap: 1.25rem;
  grid-template-columns: 1fr;
}
.projects .card {
  padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: color-mix(in oklab, var(--card) 85%, var(--bg));
  transition: transform .18s ease, box-shadow .25s ease, border-color .25s ease;
}
.projects .project-thumb {
  display: block;
  aspect-ratio: 16 / 9;
  margin: 0 0 .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in oklab, var(--card) 80%, var(--bg));
  overflow: hidden;
}
.projects .project-thumb img {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  /* Show the top part of the screenshot (crop from top instead of center) */
  object-position: top center;
}
.projects .card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in oklab, var(--accent) 35%, var(--border));
  box-shadow: var(--shadow-2);
}
.projects .card:hover .project-thumb {
  border-color: color-mix(in oklab, var(--accent) 35%, var(--border));
}

@media (min-width: 640px) {
  .projects .cards { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
  .hero { grid-template-columns: 1fr; justify-items: start; }
}

.skills ul { display: flex; flex-wrap: wrap; gap: .4rem .6rem; list-style: none; padding: 0; margin: 0; }
.skills li {
  padding: .3rem .5rem; border: 1px solid var(--border); border-radius: 0;
  background: transparent;
  transition: transform .16s ease, background .2s ease, border-color .2s ease, color .2s ease;
}
.skills li:hover {
  background: color-mix(in oklab, var(--card) 70%, var(--bg));
  border-color: color-mix(in oklab, var(--accent) 35%, var(--border));
  color: var(--fg);
  transform: translateY(-1px);
}

/* Grouped skills layout */
.skill-groups { display: grid; gap: 1rem 1.25rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .skill-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.skill-group { margin: .25rem 0 .75rem; }
.skills .group-title {
  margin: 0 0 .5rem;
  font-size: .9rem; line-height: 1.2;
  text-transform: uppercase; letter-spacing: .06em; font-weight: 700;
  color: var(--muted);
}

footer { border-top: 1px solid var(--border); color: var(--muted); padding: 1.5rem 0; font-size: .95rem; }

/* Animations */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

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

/* --- Dark mode hover visibility improvements --- */
/* Lighten hovers only in dark theme to improve affordance without affecting light theme */
:root[data-theme="dark"] .btn:hover {
  background: linear-gradient(
    180deg,
    color-mix(in oklab, var(--chrome-top) 70%, #ffffff 30%),
    color-mix(in oklab, var(--chrome-bottom) 80%, #ffffff 20%)
  );
  border-color: color-mix(in oklab, var(--chrome-edge) 60%, #ffffff 40%);
}

:root[data-theme="dark"] .btn.primary:hover {
  background: linear-gradient(
    180deg,
    color-mix(in oklab, var(--accent) 82%, #ffffff 18%),
    color-mix(in oklab, var(--accent) 75%, #000000 25%)
  );
  border-color: color-mix(in oklab, var(--accent) 55%, #ffffff 45%);
}

:root[data-theme="dark"] section:hover {
  background: linear-gradient(
    180deg,
    color-mix(in oklab, var(--chrome-top) 78%, #ffffff 22%),
    color-mix(in oklab, var(--chrome-bottom) 86%, #ffffff 14%)
  );
  border-color: color-mix(in oklab, var(--chrome-edge) 55%, #ffffff 45%);
}

:root[data-theme="dark"] .projects .card:hover {
  background: linear-gradient(
    180deg,
    color-mix(in oklab, var(--chrome-top) 74%, #ffffff 26%),
    color-mix(in oklab, var(--chrome-bottom) 84%, #ffffff 16%)
  );
  border-color: color-mix(in oklab, var(--chrome-edge) 55%, #ffffff 45%);
}

:root[data-theme="dark"] .skills li:hover {
  background: linear-gradient(
    180deg,
    color-mix(in oklab, var(--chrome-top) 76%, #ffffff 24%),
    color-mix(in oklab, var(--chrome-bottom) 86%, #ffffff 14%)
  );
  border-color: color-mix(in oklab, var(--chrome-edge) 55%, #ffffff 45%);
}

/* ---- Two-column resume layout (reference-inspired), keeping current color theme ---- */
.layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
  padding-top: 1.5rem;
}

.sidebar {
  position: sticky;
  top: 72px; /* leaves room for theme switch */
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

/* Chrome surface in dark theme for the sidebar */
:root[data-theme="dark"] .sidebar {
  background: linear-gradient(180deg, var(--chrome-top), var(--chrome-bottom));
  border-color: var(--chrome-edge);
}

.identity { text-align: left; margin-top: .75rem; }
.identity .name { font-size: clamp(1.4rem, 1.2rem + 1vw, 2rem); line-height: 1.2; margin: 0 0 .25rem; }
.identity .role { color: var(--muted); margin: 0; }

.side-nav { margin-top: 1rem; }
.side-nav ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .25rem; }
.side-nav a { display: block; padding: .5rem .6rem; border-radius: var(--radius-sm); color: var(--fg); border: 1px solid transparent; }
.side-nav a:hover { background: color-mix(in oklab, var(--card) 80%, var(--bg)); border-color: color-mix(in oklab, var(--accent) 30%, var(--border)); }
:root[data-theme="dark"] .side-nav a:hover {
  background: linear-gradient(180deg, color-mix(in oklab, var(--chrome-top) 85%, #fff 15%), var(--chrome-bottom));
  border-color: color-mix(in oklab, var(--chrome-edge) 65%, #ffffff 35%);
}

.side-actions { margin-top: 1rem; display: grid; gap: .5rem; }
.side-actions .btn { width: 100%; text-align: center; }

.content { min-width: 0; padding-top: .5rem; }

/* Flatten sections inside the content to match resume look */
.content section { background: transparent; border: 0; padding: 1.5rem; margin: 2rem auto; border-radius: 0; }
.content section + section { border-top: 1px solid var(--border); padding-top: 2rem; margin-top: 2rem; }
.content section h2 { font-size: .95rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 1rem; }

/* Experience timeline */
.experience { border-left: 1px solid var(--border); padding-left: 1rem; }
.experience .item { border-top: 0; padding: 1rem 0 1rem 1rem; margin: 0; position: relative; }
/* Remove circular timeline markers (dots) before each item as requested */
.experience .item::before { content: none; }
/* Remove bullet dots from lists inside Experience items */
.experience ul { list-style: none; padding-left: 0; margin: .5rem 0 0; }
.experience ul li { padding-left: 0; }

/* Projects adjustments within flatter content */
.projects .cards { gap: 1rem; }
.projects .card { background: transparent; border-radius: var(--radius-sm); }
:root[data-theme="dark"] .projects .card { background: color-mix(in oklab, var(--card) 75%, var(--bg)); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; gap: 1rem; }
  .sidebar { position: static; }
  .side-nav ul { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
}

/* --- Duo wrapper to place Education and Contact side by side on wide screens --- */
.duo { display: grid; gap: 1.25rem; }
@media (min-width: 1024px) {
  .duo { grid-template-columns: 1fr 1fr; align-items: start; }
}
