/* ==========================================================================
   nanofaktura — industrial precision aesthetic
   ========================================================================== */

/* ========== Custom Properties ========== */
:root {
  /* Typography */
  --font-display: "Fraunces", "Times New Roman", Georgia, serif;
  --font-mono: "Ubuntu Mono", "Courier New", ui-monospace, monospace;

  /* Spacing scale */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2rem;
  --s-7: 3rem;
  --s-8: 4rem;
  --s-9: 6rem;
  --s-10: 8rem;

  /* Colors */
  --bg-0: #0a0a0a;
  --bg-1: #121212;
  --bg-2: #181818;
  --bg-hover: #1e1e1e;

  --fg-0: #ededed;
  --fg-1: #b0b0b0;
  --fg-2: #858585;
  --fg-3: #4a4a4a;

  --accent: #29a65f;
  --accent-bright: #3dd476;
  --accent-dim: rgba(41, 166, 95, 0.15);
  --accent-line: rgba(41, 166, 95, 0.35);

  --warn: #f5a524;

  --border-0: rgba(255, 255, 255, 0.06);
  --border-1: rgba(255, 255, 255, 0.12);
  --grid-color: rgba(255, 255, 255, 0.035);

  /* Layout */
  --max-width: 1280px;
  --gutter-x: clamp(1rem, 4vw, 3rem);
  --gutter-y: clamp(3rem, 8vw, 6rem);

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Transitions */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ========== Reset ========== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ========== Base ========== */
html {
  height: 100%;
  scroll-behavior: smooth;
  scrollbar-color: var(--accent-dim) var(--bg-0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-0);
  color: var(--fg-0);
  font-family: var(--font-mono);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
  position: relative;
}

::selection {
  background: var(--accent);
  color: var(--bg-0);
}

a {
  color: inherit;
  text-decoration: none;
}

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

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

/* ========== Utilities ========== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding-inline: var(--gutter-x);
}

.skip-link {
  position: absolute;
  top: -100px;
  left: var(--s-4);
  padding: var(--s-3) var(--s-4);
  background: var(--accent);
  color: var(--bg-0);
  z-index: 100;
  transition: top 0.2s;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

.skip-link:focus {
  top: var(--s-4);
}

/* ========== Background layers ========== */
.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 0%, transparent 90%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 0%, transparent 90%);
}

.bg-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.14;
  mix-blend-mode: screen;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.45 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

body > header,
body > main,
body > footer {
  position: relative;
  z-index: 2;
}

/* ========== Typography ========== */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 144;
}

.mono-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-2);
  font-weight: 400;
}

/* ========== Header ========== */
.site-header {
  padding-block: var(--s-5);
  border-bottom: 1px solid var(--border-0);
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--bg-0) 85%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-5);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--fg-0);
  letter-spacing: 0;
  transition: color 0.25s var(--ease);
}

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

.brand-mark {
  color: var(--fg-2);
  transition: color 0.25s var(--ease);
}

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

.brand-wordmark {
  width: 130px;
  height: auto;
}

.header-meta {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--fg-1);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent), 0 0 20px var(--accent-dim);
  animation: pulse 2.4s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(0.85); }
}

/* ========== Hero ========== */
.hero {
  position: relative;
  padding-block: clamp(4rem, 12vh, 8rem) clamp(4rem, 10vh, 7rem);
  border-bottom: 1px solid var(--border-0);
  overflow: hidden;
}

.hero .container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: clamp(2rem, 5vw, 3.5rem);
  position: relative;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 55% 45% at 50% 55%,
      rgba(41, 166, 95, 0.10) 0%,
      transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.hero .container > * {
  position: relative;
  z-index: 1;
}

.hero-corners {
  position: absolute;
  inset: 0;
  pointer-events: none;
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: 1rem;
  z-index: 2;
}

.hero-corners > span {
  position: absolute;
  opacity: 0.6;
}

.hero-corners > span:nth-child(1) { top: var(--s-5); left: var(--s-5); }
.hero-corners > span:nth-child(2) { top: var(--s-5); right: var(--s-5); }
.hero-corners > span:nth-child(3) { bottom: var(--s-5); left: var(--s-5); }
.hero-corners > span:nth-child(4) { bottom: var(--s-5); right: var(--s-5); }

.hero-eyebrow {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s-3);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-2);
  animation: fade-in 0.8s var(--ease) both;
}

.hero-eyebrow .dot-sep {
  color: var(--fg-3);
}

.hero-eyebrow .marker {
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
}

/* Hero wordmark — the new hero headline */
.hero-wordmark {
  display: flex;
  justify-content: center;
  margin: 0;
  width: 100%;
}

.hero-wordmark .wordmark {
  width: min(760px, 88vw);
  animation: wordmark-in 1.1s cubic-bezier(0.2, 0.7, 0.2, 1) 0.2s both;
}

@keyframes wordmark-in {
  from {
    opacity: 0;
    transform: scale(0.96);
    filter: drop-shadow(0 0 0px rgba(41, 166, 95, 0));
  }
  to {
    opacity: 1;
    transform: scale(1);
    filter: drop-shadow(0 0 80px rgba(41, 166, 95, 0.18));
  }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Hero tagline — serif caption below wordmark */
.hero-tagline {
  font-family: var(--font-display);
  font-size: clamp(1.125rem, 2.2vw, 1.625rem);
  font-weight: 300;
  color: var(--fg-1);
  font-variation-settings: "opsz" 48;
  line-height: 1.35;
  letter-spacing: -0.01em;
  max-width: 32ch;
  animation: fade-in 0.8s var(--ease) 0.7s both;
  opacity: 0;
}

.hero-tagline em {
  font-style: italic;
  color: var(--accent);
  font-weight: 400;
}

.hero-specs {
  max-width: 44rem;
  width: 100%;
  text-align: left;
  animation: fade-in 0.8s var(--ease) 0.9s both;
  opacity: 0;
}

.hero-specs dl {
  display: grid;
  gap: var(--s-2);
}

.spec-row {
  display: grid;
  grid-template-columns: 9rem 1fr;
  align-items: baseline;
  gap: var(--s-3);
  padding-block: var(--s-3);
  border-bottom: 1px solid var(--border-0);
  font-family: var(--font-mono);
}

.spec-row dt {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-2);
  position: relative;
}

.spec-row dt::before {
  content: "/";
  color: var(--fg-3);
  margin-right: var(--s-2);
}

.spec-row dd {
  font-size: 0.95rem;
  color: var(--fg-0);
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
}

.spec-row dd .accent { color: var(--accent); }

/* Wordmark base (used in hero) */
.wordmark {
  height: auto;
  user-select: none;
  transition: transform 0.7s var(--ease), filter 0.7s var(--ease);
}

@media (hover: hover) {
  .wordmark:hover {
    transform: scale(1.015);
    filter: drop-shadow(0 0 120px rgba(41, 166, 95, 0.28)) !important;
  }
}

.hero-mark svg {
  width: 100%;
  height: auto;
}

/* ========== Section header ========== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding-block: var(--s-5);
  border-bottom: 1px solid var(--border-1);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.section-label {
  color: var(--fg-0);
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
}

.section-label::before {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--accent);
  display: inline-block;
}

.section-count {
  color: var(--fg-2);
}

/* ========== Projects ledger ========== */
.projects {
  padding-block: var(--gutter-y);
}

.project-list {
  list-style: none;
}

.project-item {
  position: relative;
  border-bottom: 1px solid var(--border-0);
}

.project-item:first-child {
  border-top: 1px solid var(--border-0);
}

.project-row {
  display: grid;
  grid-template-columns: auto auto 1fr auto auto auto;
  gap: var(--s-5);
  align-items: center;
  width: 100%;
  padding: var(--s-6) var(--s-3);
  text-align: left;
  font-family: var(--font-mono);
  color: var(--fg-1);
  background: transparent;
  transition: background-color 0.35s var(--ease), color 0.35s var(--ease);
  position: relative;
}

.project-row::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--accent-dim) 0%, transparent 40%);
  opacity: 0;
  transition: opacity 0.35s var(--ease);
  pointer-events: none;
}

@media (hover: hover) {
  .project-row:hover {
    color: var(--fg-0);
  }

  .project-row:hover::before {
    opacity: 1;
  }

  .project-row:hover .proj-title {
    transform: translateX(var(--s-3));
    color: var(--accent);
  }

  .project-row:hover .proj-swatch {
    transform: scale(1.1);
    box-shadow: 0 0 0 1px var(--accent-line), 0 8px 32px rgba(41, 166, 95, 0.2);
  }

  .project-row:hover .proj-arrow {
    color: var(--accent);
    transform: translate(6px, -6px);
  }
}

.project-row:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

.proj-num {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
  min-width: 3.5rem;
}

.proj-swatch {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  background: var(--card-bg);
  border: 1px solid var(--border-0);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
  flex-shrink: 0;
}

.proj-swatch img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.proj-title {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(1.5rem, 3.5vw, 2.5rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--fg-0);
  transition: transform 0.35s var(--ease), color 0.35s var(--ease);
  font-variation-settings: "opsz" 72;
}

.proj-year {
  font-size: 0.85rem;
  color: var(--fg-2);
  font-variant-numeric: tabular-nums;
}

.proj-kind {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  color: var(--fg-2);
  text-transform: uppercase;
  padding: var(--s-1) var(--s-3);
  border: 1px solid var(--border-1);
  border-radius: 2px;
}

.proj-arrow {
  font-family: var(--font-mono);
  color: var(--fg-3);
  font-size: 1.25rem;
  transition: transform 0.35s var(--ease), color 0.35s var(--ease);
  line-height: 1;
}

/* ========== Dialog ========== */
dialog {
  background: var(--bg-1);
  color: var(--fg-0);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  width: min(560px, calc(100vw - 2rem));
  max-height: 85vh;
  padding: 0;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.6),
    0 0 0 1px var(--border-0),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

dialog[open] {
  animation: dialog-in 0.35s var(--ease);
}

@keyframes dialog-in {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.dialog-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--s-4);
  align-items: center;
  padding: var(--s-5);
  border-bottom: 1px solid var(--border-0);
  background: var(--bg-2);
}

.dialog-meta {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  color: var(--fg-2);
  text-transform: uppercase;
}

.dialog-head h3 {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 1.75rem;
  line-height: 1.1;
  color: var(--fg-0);
  font-variation-settings: "opsz" 48;
  letter-spacing: -0.015em;
}

.close-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-2);
  border-radius: 50%;
  transition: background 0.2s, color 0.2s;
  font-size: 1rem;
}

.close-btn:hover {
  background: var(--bg-hover);
  color: var(--fg-0);
}

.dialog-body {
  padding: var(--s-5);
  overflow-y: auto;
  max-height: calc(85vh - 100px);
}

.dialog-body dl {
  display: grid;
  gap: var(--s-5);
}

.dialog-body dt {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  color: var(--fg-2);
  text-transform: uppercase;
  margin-bottom: var(--s-2);
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.dialog-body dt::before {
  content: "";
  width: 12px;
  height: 1px;
  background: var(--accent);
}

.dialog-body dd {
  color: var(--fg-0);
  line-height: 1.6;
}

.dialog-body a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-line);
  transition: color 0.2s, border-color 0.2s;
}

.dialog-body a:hover {
  color: var(--accent-bright);
  border-color: var(--accent-bright);
}

.tech-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.tech-list span {
  padding: var(--s-1) var(--s-3);
  border: 1px solid var(--border-1);
  border-radius: 2px;
  font-size: 0.8rem;
  color: var(--fg-1);
  letter-spacing: 0.04em;
}

/* ========== Contact ========== */
.contact {
  padding-block: var(--gutter-y);
  border-top: 1px solid var(--border-0);
}

.contact-headline {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(2rem, 7vw, 4.5rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin-block: var(--s-6) var(--s-5);
  font-variation-settings: "opsz" 144;
  overflow-wrap: anywhere;
}

.contact-email {
  display: inline-block;
  color: var(--fg-0);
  position: relative;
  transition: color 0.3s var(--ease);
}

.contact-email::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0.1em;
  height: 1px;
  width: 100%;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.5s var(--ease);
}

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

.contact-email:hover::after {
  transform: scaleX(1);
}

.contact-actions {
  display: flex;
  gap: var(--s-3);
  margin-top: var(--s-6);
  flex-wrap: wrap;
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-6);
  border: 1px solid var(--border-1);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-0);
  background: transparent;
  cursor: pointer;
  transition: border-color 0.3s var(--ease), color 0.3s var(--ease), background 0.3s var(--ease), transform 0.3s var(--ease);
}

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

.ghost-btn:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
}

.ghost-btn .arrow {
  transition: transform 0.3s var(--ease);
}

.ghost-btn:hover .arrow {
  transform: translateX(4px);
}

/* ========== Footer ========== */
.site-footer {
  padding-block: var(--s-6);
  border-top: 1px solid var(--border-0);
  margin-top: auto;
}

.site-footer .container {
  display: flex;
  justify-content: space-between;
  gap: var(--s-5);
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-2);
}

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

/* ========== Toast ========== */
#toast {
  position: fixed;
  left: 50%;
  bottom: 2rem;
  transform: translate(-50%, 1rem);
  background: var(--bg-2);
  color: var(--fg-0);
  padding: var(--s-3) var(--s-5);
  border-radius: 999px;
  border: 1px solid var(--accent);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 32px var(--accent-dim);
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
}

#toast::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ========== Responsive ========== */


/* Project row compact at tablet */
@media (max-width: 900px) {
  .project-row {
    grid-template-columns: auto auto 1fr auto;
    gap: var(--s-4);
    padding-block: var(--s-5);
  }

  .proj-year,
  .proj-arrow {
    display: none;
  }
}

/* Mobile refinements */
@media (max-width: 640px) {
  :root {
    --gutter-x: 1rem;
  }

  .site-header .container {
    flex-direction: row;
  }

  .header-meta .status-label {
    display: none;
  }

  .hero-eyebrow {
    font-size: 0.65rem;
  }

  .hero-headline {
    max-width: 100%;
  }

  .spec-row {
    grid-template-columns: 1fr;
    gap: var(--s-1);
    padding-block: var(--s-3);
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--s-2);
  }

  .project-row {
    grid-template-columns: auto auto 1fr auto;
    gap: var(--s-3);
    padding: var(--s-4) var(--s-2);
    align-items: center;
  }

  .proj-num {
    min-width: auto;
    font-size: 0.65rem;
  }

  .proj-swatch {
    width: 36px;
    height: 36px;
    padding: 4px;
  }

  .proj-title {
    font-size: clamp(1.25rem, 5vw, 1.75rem);
  }

  .proj-kind {
    display: none;
  }

  .contact-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .ghost-btn {
    justify-content: space-between;
  }

  .site-footer .container {
    gap: var(--s-2);
  }
}

/* Hide pulse/glow on no-hover devices */
@media (hover: none) {
  .project-row:active::before {
    opacity: 0.6;
  }
}

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