:root {
  --bg: #0d0c09;
  --bg-elevated: #161410;
  --bg-card: #1c1a15;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f0ebe0;
  --text-muted: #9a8f7a;
  --accent: #c8a45a;
  --accent-dim: rgba(200, 164, 90, 0.12);
  --accent-strong: #b08e3a;
  --radius: 4px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --serif: "Playfair Display", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --max: 1100px;
  --header-h: 72px;
  --enable-typing-anim: 1;
}

@media (max-width: 768px) {
  :root {
    --enable-typing-anim: 0;
  }
}

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

html {
  scroll-behavior: smooth;
  background: var(--bg);
  /* Reserve scrollbar gutter to prevent layout shift between
     pages that overflow and pages that don't. */
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  /* Block any unintended horizontal scroll. `clip` (unlike `hidden`)
     does not break position: sticky on descendants. */
  overflow-x: clip;
  /* Ensure body always fills the viewport so the page background
     reaches into the iOS bottom safe area. */
  min-height: 100vh;
  min-height: 100dvh;
}

/* Long words (e.g. Polish translations) wrap inside narrow containers. */
p, li, h1, h2, h3, h4, .card__title, .card__subtitle, .card__list {
  overflow-wrap: break-word;
}

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

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

.skip-link {
  position: absolute;
  left: -999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
  width: auto;
  height: auto;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--bg);
  z-index: 100;
  border-radius: var(--radius);
}

/* ─── Header ──────────────────────────────────────────────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(13, 12, 9, 0.94);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  /* Push content below the iOS notch/dynamic island. */
  padding-top: env(safe-area-inset-top);
}

.site-header__inner {
  max-width: var(--max);
  margin: 0 auto;
  /* Respect side safe areas in landscape (notched devices). */
  padding-left: max(2rem, env(safe-area-inset-left));
  padding-right: max(2rem, env(safe-area-inset-right));
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  text-decoration: none;
}

.logo:hover {
  color: var(--accent);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  justify-content: flex-end;
}

.nav a {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  transition: color 0.15s;
}

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

/* ─── Hero ────────────────────────────────────────────────── */

.hero {
  display: flex;
  /* 100dvh excludes the iOS browser toolbars so the hero fills the
     visible viewport, while 100vh acts as a fallback for older WebKit. */
  min-height: calc(100vh - var(--header-h));
  min-height: calc(100dvh - var(--header-h));
  overflow: hidden;
}

.hero__text-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(3rem, 7vw, 6rem) clamp(1.5rem, 5vw, 5rem);
  padding-left: max(clamp(1.5rem, 5vw, 5rem), env(safe-area-inset-left));
  padding-right: max(clamp(1.5rem, 5vw, 5rem), env(safe-area-inset-right));
  background: var(--bg);
}

.hero__photo-side {
  width: 44%;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.hero__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}

.hero__photo-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, var(--bg) 0%, transparent 30%);
  pointer-events: none;
}

.hero__eyebrow {
  margin: 0 0 1rem;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero__divider {
  width: 3rem;
  height: 1px;
  background: var(--accent);
  border: none;
  margin: 0 0 1.75rem;
}

.hero__title {
  margin: 0 0 1.25rem;
  font-family: var(--serif);
  font-size: clamp(2.75rem, 5.5vw, 4.5rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.05;
  color: var(--text);
}

.hero__lead {
  margin: 0 0 2.5rem;
  max-width: 38rem;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.8;
}

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

/* ─── Buttons ─────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.85rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.btn--primary {
  background: var(--accent);
  color: #0d0c09;
}

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

.btn--ghost {
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text);
  background: transparent;
}

.btn--ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ─── Sections ────────────────────────────────────────────── */

.section {
  padding-top: 5rem;
  padding-bottom: 5rem;
  padding-left: max(2rem, env(safe-area-inset-left));
  padding-right: max(2rem, env(safe-area-inset-right));
}

.section--alt {
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.section--contact {
  /* Add home-indicator clearance on iPhone X+ */
  padding-bottom: calc(6rem + env(safe-area-inset-bottom));
}

.container {
  max-width: var(--max);
  margin: 0 auto;
}

.container--narrow {
  max-width: 620px;
}

.section__eyebrow {
  margin: 0 0 0.6rem;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

.section__title {
  margin: 0 0 0.75rem;
  font-family: var(--serif);
  font-size: clamp(1.65rem, 2.5vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.section__divider {
  width: 3rem;
  height: 1px;
  background: var(--accent);
  border: none;
  margin: 0 0 2.75rem;
}

.prose {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.8;
}

/* ─── Timeline / Cards ────────────────────────────────────── */

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  box-shadow: var(--shadow);
}

.card__title {
  margin: 0 0 0.25rem;
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 700;
}

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

.card__meta {
  margin: 0.4rem 0 0;
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.card__link {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
}

.card__list {
  margin: 1rem 0 0;
  padding-left: 1.15rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

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

/* ─── Skills ──────────────────────────────────────────────── */

.skills-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.skill-block--wide {
  grid-column: 1 / -1;
}

.skill-block__title {
  margin: 0 0 0.75rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

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

.tags li {
  padding: 0.35rem 0.85rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ─── Contact ─────────────────────────────────────────────── */

.contact-list {
  list-style: none;
  margin: 2rem 0 0;
  padding: 0;
}

.contact-list li {
  margin-bottom: 0.75rem;
  font-size: 1.05rem;
}

/* ─── Footer ──────────────────────────────────────────────── */

.site-footer {
  padding-top: 2.5rem;
  padding-bottom: calc(2.5rem + env(safe-area-inset-bottom));
  padding-left: max(2rem, env(safe-area-inset-left));
  padding-right: max(2rem, env(safe-area-inset-right));
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.site-footer__inner {
  text-align: center;
}

.site-footer a {
  color: var(--text-muted);
}

.site-footer a:hover {
  color: var(--accent);
}

/* ─── Responsive ──────────────────────────────────────────── */

@media (max-width: 768px) {
  .hero {
    flex-direction: column;
    min-height: auto;
  }

  .hero__text-side {
    order: 2;
    padding: 3rem 1.5rem 3.5rem;
    padding-left: max(1.5rem, env(safe-area-inset-left));
    padding-right: max(1.5rem, env(safe-area-inset-right));
  }

  .hero__photo-side {
    order: 1;
    width: 100%;
    height: 60vw;
    max-height: 380px;
  }

  .hero__photo-overlay {
    background: linear-gradient(to bottom, transparent 55%, var(--bg) 100%);
  }

  .section {
    padding-top: 3.5rem;
    padding-bottom: 3.5rem;
    padding-left: max(1.25rem, env(safe-area-inset-left));
    padding-right: max(1.25rem, env(safe-area-inset-right));
  }

  .section--contact {
    padding-bottom: calc(4rem + env(safe-area-inset-bottom));
  }

  .site-header__inner {
    flex-wrap: wrap;
    height: auto;
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
    padding-left: max(1.25rem, env(safe-area-inset-left));
    padding-right: max(1.25rem, env(safe-area-inset-right));
  }

  .nav {
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    gap: 0.25rem 0.5rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .nav a {
    white-space: nowrap;
    /* Larger touch target — meets 44px minimum hit area. */
    padding: 0.7rem 0.5rem;
    font-size: 0.78rem;
  }

  /* Hero CTAs and links: comfortable thumb targets */
  .btn {
    min-height: 48px;
    padding: 0.9rem 1.5rem;
  }

  .contact-list a {
    display: inline-block;
    padding: 0.5rem 0;
  }

  /* Tappable card links get extra room around the link text. */
  .card__link a {
    display: inline-block;
    padding: 0.25rem 0;
  }

  .site-footer {
    padding-left: max(1.25rem, env(safe-area-inset-left));
    padding-right: max(1.25rem, env(safe-area-inset-right));
  }
}

/* ─── Hero entry animations (above-the-fold, CSS-driven) ─────── */

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(28px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes scaleInX {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

.hero__eyebrow {
  animation: fadeUp 0.65s cubic-bezier(0.16, 1, 0.3, 1) 0.05s both;
}

.hero__divider {
  transform-origin: left center;
  animation: scaleInX 0.55s cubic-bezier(0.16, 1, 0.3, 1) 0.25s both;
}

.hero__title {
  animation: fadeUp 0.75s cubic-bezier(0.16, 1, 0.3, 1) 0.35s both;
}

.hero__lead {
  animation: fadeUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.5s both;
}

.hero__actions {
  animation: fadeUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.65s both;
}

.hero__photo-side {
  animation: fadeIn 1.1s ease 0.1s both;
}

/* ─── Scroll-reveal (IntersectionObserver-driven) ────────────── */

.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition:
    opacity  0.65s cubic-bezier(0.16, 1, 0.3, 1) var(--delay, 0s),
    transform 0.65s cubic-bezier(0.16, 1, 0.3, 1) var(--delay, 0s);
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Line variant: scales in from the left instead of fading up */
.reveal--line {
  opacity: 1;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1) var(--delay, 0s);
}

.reveal--line.is-visible {
  transform: scaleX(1);
}

/* ─── Language toggle button ──────────────────────────────── */

.lang-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* 44 × 44 minimum touch target per WCAG 2.5.5 / Apple HIG. */
  min-width: 44px;
  min-height: 44px;
  padding: 0.5rem 0.6rem;
  line-height: 0;
  cursor: pointer;
  flex-shrink: 0;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lang-btn:hover {
  border-color: var(--accent);
  transform: scale(1.1);
}

.lang-flag {
  display: block;
  width: 28px;
  height: 20px;
  object-fit: cover;
  border-radius: 2px;
}

/* ─── Hero firstname (locked width during typing only) ─────── */

#hero-firstname {
  display: inline-block;
  vertical-align: baseline;
  min-width: 0;
  text-align: left;
  white-space: nowrap;
  transition: min-width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ─── Typing cursor ───────────────────────────────────────── */

.type-cursor {
  color: var(--accent);
  font-weight: 300;
  margin-left: 1px;
  animation: cursor-blink 0.7s step-end infinite;
}

@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}
