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

/* ── Variables ───────────────────────────────────────── */
:root {
  --bg:          #f8f8f7;
  --surface:     #ffffff;
  --border:      #e6e6e4;
  --text:        #111110;
  --text-2:      #6b6b68;
  --text-3:      #aaa9a6;
  --accent:      #2563eb;
  --accent-bg:   #eff6ff;
  --radius:      10px;
  --radius-sm:   6px;
  --shadow:      0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.05);
  --shadow-hover:0 4px 8px rgba(0,0,0,0.06), 0 12px 32px rgba(0,0,0,0.08);
}

/* ── Base ────────────────────────────────────────────── */
html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Nav ─────────────────────────────────────────────── */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(248, 248, 247, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  font-weight: 650;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 2rem;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-2);
  font-size: 0.875rem;
  transition: color 0.15s;
}

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

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.2s;
}

/* ── Sections ────────────────────────────────────────── */
section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 6rem 2rem;
}

section:not(#hero) {
  border-top: 1px solid var(--border);
}

h2 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.035em;
  margin-bottom: 2rem;
}

/* ── Hero ────────────────────────────────────────────── */
#hero {
  padding: 8rem 2rem 6rem;
  border-top: none;
}

.hero-eyebrow {
  font-size: 1rem;
  color: var(--text-2);
  margin-bottom: 0.4rem;
}

#hero h1 {
  font-size: clamp(3rem, 7vw, 5.5rem);
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1;
  margin-bottom: 1.5rem;
}

.hero-desc {
  font-size: 1.1rem;
  color: var(--text-2);
  max-width: 520px;
  line-height: 1.7;
  margin-bottom: 2.5rem;
}

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

/* ── Buttons ─────────────────────────────────────────── */
.btn-primary {
  display: inline-block;
  padding: 0.65rem 1.4rem;
  background: var(--text);
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: opacity 0.15s;
}

.btn-primary:hover { opacity: 0.75; }

.btn-secondary {
  display: inline-block;
  padding: 0.65rem 1.4rem;
  background: transparent;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid var(--border);
  transition: border-color 0.15s, background 0.15s;
}

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

/* ── About ───────────────────────────────────────────── */
.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: start;
}

.about-text p {
  color: var(--text-2);
  line-height: 1.75;
  margin-bottom: 1rem;
  font-size: 1rem;
}

.about-text p:last-child { margin-bottom: 0; }

.skill-group {
  margin-bottom: 1.5rem;
}

.skill-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: 0.6rem;
}

.skill-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.skill-tag {
  padding: 0.3rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 0.8rem;
  color: var(--text-2);
}

/* ── Filter Bar ──────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 2rem;
  margin-top: -0.75rem;
}

.filter-btn {
  padding: 0.3rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-2);
  transition: all 0.15s;
  line-height: 1.6;
}

.filter-btn:hover {
  border-color: var(--text-2);
  color: var(--text);
}

.filter-btn.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

/* ── Cards Grid ──────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

/* ── Card ────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: box-shadow 0.2s, transform 0.2s;
  cursor: pointer;
  animation: fadeUp 0.3s ease both;
}

.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card-title {
  font-size: 0.975rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.35;
}

.card-desc {
  font-size: 0.85rem;
  color: var(--text-2);
  line-height: 1.65;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.6;
}

.tag-cat   { background: var(--accent-bg); color: var(--accent); }
.tag-tech  { background: #f4f4f3; color: var(--text-2); }
.tag-auto  { background: #f0fdf4; color: #16a34a; }

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.25rem;
}

.card-date {
  font-size: 0.75rem;
  color: var(--text-3);
}

.card-links {
  display: flex;
  gap: 0.75rem;
}

.card-link {
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
}

.card-link:hover { text-decoration: underline; }

/* ── Automations ─────────────────────────────────────── */
.section-subtitle {
  color: var(--text-2);
  margin-top: -1.25rem;
  margin-bottom: 2rem;
  font-size: 0.95rem;
  line-height: 1.6;
}

/* ── Contact ─────────────────────────────────────────── */
.contact-text {
  color: var(--text-2);
  margin-bottom: 1.75rem;
  font-size: 1rem;
  line-height: 1.7;
}

/* ── Contact Form ────────────────────────────────────── */
.contact-form {
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.01em;
}

.form-group input,
.form-group textarea {
  padding: 0.65rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  resize: vertical;
  outline: none;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-3);
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group input.invalid,
.form-group textarea.invalid {
  border-color: #ef4444;
}

.contact-form .btn-primary {
  align-self: flex-start;
}

.contact-form .btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.contact-success {
  max-width: 640px;
  padding: 2.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  animation: fadeUp 0.3s ease both;
}

.success-icon {
  width: 48px;
  height: 48px;
  background: #f0fdf4;
  color: #16a34a;
  border-radius: 50%;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}

.success-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.success-sub {
  font-size: 0.875rem;
  color: var(--text-2);
}

/* ── Footer ──────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 2rem;
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-3);
  font-size: 0.8rem;
}

/* ── Animations ──────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes modalRise {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Modal ───────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
}

.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 17, 16, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: modalFade 0.2s ease both;
}

.modal-sheet {
  position: relative;
  width: 100%;
  max-width: 720px;
  max-height: calc(100vh - 4rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08), 0 24px 64px rgba(0,0,0,0.12);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalRise 0.25s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 2;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.9);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font-size: 1.25rem;
  line-height: 1;
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s, transform 0.15s;
}

.modal-close:hover {
  color: var(--text);
  border-color: var(--text-2);
  transform: rotate(90deg);
}

.modal-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  flex: 1;
}

.modal-hero {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--accent-bg);
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}

.modal-hero .placeholder-img { border-radius: 0; }

.modal-content {
  padding: 1.75rem 2rem 2rem;
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.25;
  margin-bottom: 0.75rem;
  max-width: calc(100% - 2.5rem);
}

.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-meta .card-date {
  margin-left: 0.25rem;
}

.modal-desc {
  color: var(--text-2);
  font-size: 0.95rem;
  line-height: 1.75;
  margin-bottom: 1.75rem;
}

.modal-desc p + p { margin-top: 0.75rem; }

.modal-section-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  margin-bottom: 0.75rem;
}

.modal-gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin-bottom: 1.75rem;
}

.modal-gallery .placeholder-img {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

/* ── Placeholder image (striped) ─────────────────────── */
.placeholder-img {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    repeating-linear-gradient(
      135deg,
      rgba(17,17,16,0.035) 0 10px,
      rgba(17,17,16,0.00) 10px 20px
    ),
    var(--ph-tint, var(--accent-bg));
  color: var(--text-3);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  text-align: center;
  padding: 0.5rem;
}

.placeholder-img span {
  max-width: 90%;
  line-height: 1.4;
}

.placeholder-img.is-hero span { font-size: 0.78rem; }

.modal-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: var(--radius-sm);
}

.modal-img.is-hero {
  border-radius: 0;
}

.modal-gallery .modal-img {
  aspect-ratio: 4 / 3;
  height: auto;
}

body.modal-open { overflow: hidden; }

/* ── Tweaks panel ────────────────────────────────────── */
.tweaks {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 300;
  width: 280px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  background: rgba(255,255,255,0.88);
  color: var(--text);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 12px 40px rgba(0,0,0,.12);
  font-size: 0.78rem;
  overflow: hidden;
}

.tweaks[hidden] { display: none; }

.tweaks-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 10px 10px 14px;
  border-bottom: 1px solid var(--border);
}

.tweaks-hd b { font-size: 0.8rem; font-weight: 600; letter-spacing: -0.01em; }

.tweaks-x {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-3);
  width: 24px; height: 24px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.tweaks-x:hover { background: rgba(0,0,0,0.05); color: var(--text); }

.tweaks-body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.tw-section {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  margin-top: 2px;
  margin-bottom: -4px;
}

.tw-section:first-child { margin-top: 0; }

.tw-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tw-row label.tw-label {
  font-size: 0.72rem;
  color: var(--text-2);
  font-weight: 500;
}

.tw-seg {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.tw-seg button {
  flex: 1;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-2);
  padding: 5px 8px;
  font-size: 0.72rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.tw-seg button:hover { color: var(--text); }

.tw-seg button.on {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.tw-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text);
  cursor: pointer;
}

.tw-toggle input { display: none; }

.tw-toggle .tw-switch {
  width: 32px; height: 18px;
  border-radius: 100px;
  background: var(--border);
  position: relative;
  transition: background 0.15s;
  flex-shrink: 0;
}

.tw-toggle .tw-switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  transition: transform 0.15s;
}

.tw-toggle input:checked ~ .tw-switch { background: var(--text); }
.tw-toggle input:checked ~ .tw-switch::after { transform: translateX(14px); }

.tw-swatches {
  display: flex;
  gap: 6px;
}

.tw-sw {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  background-clip: content-box;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
  transition: transform 0.15s, border-color 0.15s;
}

.tw-sw:hover { transform: scale(1.08); }
.tw-sw.on { border-color: var(--text); }

/* ── Tweak variants ──────────────────────────────────── */
body[data-accent="blue"]   { --accent: #2563eb; --accent-bg: #eff6ff; }
body[data-accent="rose"]   { --accent: oklch(0.62 0.16 15);  --accent-bg: oklch(0.97 0.02 15); }
body[data-accent="forest"] { --accent: oklch(0.52 0.12 150); --accent-bg: oklch(0.97 0.02 150); }
body[data-accent="plum"]   { --accent: oklch(0.52 0.14 320); --accent-bg: oklch(0.97 0.02 320); }
body[data-accent="mono"]   { --accent: #111110; --accent-bg: #f1f1ef; }

body[data-density="compact"] section { padding-top: 4rem; padding-bottom: 4rem; }
body[data-density="comfy"]   section { padding-top: 8rem; padding-bottom: 8rem; }
body[data-density="compact"] .cards-grid { gap: 0.75rem; }
body[data-density="compact"] .card { padding: 1.15rem; gap: 0.55rem; }
body[data-density="comfy"]   .cards-grid { gap: 1.75rem; }
body[data-density="comfy"]   .card { padding: 1.9rem; gap: 0.9rem; }

body[data-card-style="flat"] .card { box-shadow: none; }
body[data-card-style="flat"] .card:hover { box-shadow: 0 0 0 1px var(--text-2); transform: none; border-color: var(--text-2); }
body[data-card-style="soft"] .card { border-color: transparent; box-shadow: var(--shadow); }
body[data-card-style="soft"] .card:hover { box-shadow: var(--shadow-hover); }

body[data-radius="sharp"]   { --radius: 2px;  --radius-sm: 2px; }
body[data-radius="rounded"] { --radius: 10px; --radius-sm: 6px; }
body[data-radius="pill"]    { --radius: 22px; --radius-sm: 14px; }

body[data-thumbs="off"] .modal-hero { display: none; }
body[data-thumbs="off"] .modal-gallery,
body[data-thumbs="off"] .modal-section-label { display: none; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  .about-grid { grid-template-columns: 1fr; gap: 2rem; }
}

@media (max-width: 600px) {
  .nav-links {
    display: none;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 1rem 2rem;
    gap: 1rem;
  }

  .nav-links.open { display: flex; }
  .nav-toggle { display: flex; }

  section { padding: 4rem 1.25rem; }
  #hero { padding: 5rem 1.25rem 4rem; }
  .cards-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .footer-inner { flex-direction: column; gap: 0.5rem; text-align: center; }

  .modal { padding: 1rem 0.75rem; }
  .modal-content { padding: 1.25rem 1.25rem 1.5rem; }
  .modal-title { font-size: 1.25rem; }
  .modal-gallery { grid-template-columns: repeat(2, 1fr); }
}
