/* ==========================================================================
   Phạm Thiên Duy — Personal brand site
   Design tokens, then layout. Light + dark through [data-theme] on <html>.
   ========================================================================== */

:root {
  --bg: #f8f7f4;
  --bg-tint: #f2f0eb;
  --surface: #ffffff;
  --surface-2: #fbfaf8;
  --ink: #101319;
  --ink-soft: #3a424c;
  --muted: #6b7480;
  --line: #e5e2da;
  --line-strong: #d5d1c6;
  --accent: #1d3a5c;
  --accent-hover: #14294048;
  --accent-ink: #ffffff;
  --accent-soft: rgba(29, 58, 92, 0.08);
  --danger: #9b2c2c;
  --ok: #1f6b45;
  --shadow-sm: 0 1px 2px rgba(16, 19, 25, 0.05);
  --shadow: 0 22px 48px -34px rgba(16, 19, 25, 0.5);
  --radius: 16px;
  --radius-sm: 10px;
  --font-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;
}

html[data-theme='dark'] {
  --bg: #0c0f13;
  --bg-tint: #10141a;
  --surface: #12161d;
  --surface-2: #161b23;
  --ink: #f3f4f6;
  --ink-soft: #c6ccd4;
  --muted: #8d97a4;
  --line: #232a34;
  --line-strong: #303a46;
  --accent: #9dbede;
  --accent-hover: #b8d2ec;
  --accent-ink: #0a0d11;
  --accent-soft: rgba(157, 190, 222, 0.12);
  --danger: #e08585;
  --ok: #74c39b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 26px 55px -34px rgba(0, 0, 0, 0.85);
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.modal-open { overflow: hidden; }

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

h1, h2, h3, h4 { margin: 0; font-weight: 500; line-height: 1.14; letter-spacing: -0.015em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 16px;
  z-index: 200;
}
.skip-link:focus { left: 12px; top: 12px; }

.wrap {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding-inline: clamp(18px, 5vw, 48px);
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s ease, background 0.25s ease;
}
.site-header.is-stuck {
  border-bottom-color: var(--line);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 72px;
}

.wordmark { display: flex; align-items: center; gap: 12px; }
.wordmark-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1;
  padding-bottom: 3px;
}
.wordmark-text { display: flex; flex-direction: column; line-height: 1.2; }
.wordmark-text strong { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.wordmark-text small {
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav { display: flex; align-items: center; gap: 6px; }
.nav a {
  position: relative;
  padding: 9px 13px;
  border-radius: 999px;
  font-size: 14.5px;
  color: var(--ink-soft);
  transition: color 0.18s ease, background 0.18s ease;
}
.nav a:hover { color: var(--ink); background: var(--accent-soft); }
.nav a.is-active { color: var(--ink); font-weight: 600; }
.nav a.is-active::after {
  content: '';
  position: absolute;
  left: 13px;
  right: 13px;
  bottom: 3px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.header-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.icon-btn:active { transform: scale(0.96); }

.menu-btn { display: none; }
.burger { display: grid; gap: 5px; }
.burger i {
  display: block;
  width: 17px;
  height: 1.6px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.22s ease, opacity 0.22s ease;
}
body.nav-open .burger i:nth-child(1) { transform: translateY(3.3px) rotate(45deg); }
body.nav-open .burger i:nth-child(2) { transform: translateY(-3.3px) rotate(-45deg); }

/* ----------------------------------- main --------------------------------- */

.site-main { flex: 1 0 auto; }
.view { padding-block: clamp(28px, 5vw, 56px) clamp(56px, 8vw, 104px); }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 18px;
}
.eyebrow::before {
  content: '';
  width: 26px;
  height: 1px;
  background: var(--accent);
}

.display {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.3rem, 7.4vw, 4.6rem);
  line-height: 1.03;
  letter-spacing: -0.025em;
}
.display em { font-style: italic; color: var(--accent); }

.h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.65rem, 3.6vw, 2.5rem);
  line-height: 1.16;
}
.h3 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.15rem, 2vw, 1.4rem);
}

.lede {
  font-size: clamp(1rem, 1.6vw, 1.16rem);
  color: var(--ink-soft);
  max-width: 62ch;
}
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.mono { font-family: var(--mono); font-size: 12.5px; letter-spacing: 0.02em; }

.section { padding-block: clamp(40px, 6vw, 76px); }
.section + .section { border-top: 1px solid var(--line); }
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: clamp(22px, 3vw, 36px);
}
.section-head .h2 { max-width: 22ch; }

.stack-sm > * + * { margin-top: 12px; }
.stack > * + * { margin-top: 20px; }
.stack-lg > * + * { margin-top: 32px; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 12px 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
  background: var(--surface);
  color: var(--ink);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink); background: var(--accent-soft); }
.btn-sm { padding: 8px 15px; font-size: 13px; }
.btn-danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14.5px;
  color: var(--accent);
}
.link-arrow span { transition: transform 0.2s ease; }
.link-arrow:hover span { transform: translateX(4px); }

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

.hero {
  display: grid;
  gap: clamp(28px, 5vw, 56px);
  align-items: center;
}
.hero-copy .display { margin-bottom: 16px; }
.hero-role {
  font-size: 14px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 22px;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }

.portrait {
  position: relative;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-2);
  aspect-ratio: 4 / 5;
  box-shadow: var(--shadow);
}
.portrait img { width: 100%; height: 100%; object-fit: cover; }
.portrait-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(120% 100% at 20% 0%, var(--accent-soft), transparent 60%),
    linear-gradient(160deg, var(--surface-2), var(--bg-tint));
}
.portrait-fallback span {
  font-family: var(--font-display);
  font-size: clamp(3.4rem, 9vw, 5.2rem);
  letter-spacing: 0.04em;
  color: var(--ink);
  opacity: 0.9;
}
.portrait-caption {
  position: absolute;
  left: 14px;
  bottom: 14px;
  right: 14px;
  padding: 10px 14px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(8px);
  font-size: 12.5px;
  color: var(--ink-soft);
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 34px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}
.stat-value {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2rem);
  line-height: 1.1;
}
.stat-label { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

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

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(20px, 2.6vw, 28px);
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.card-hover:hover { border-color: var(--line-strong); transform: translateY(-3px); box-shadow: var(--shadow); }

.grid { display: grid; gap: clamp(16px, 2.2vw, 24px); }
.grid-2 { grid-template-columns: minmax(0, 1fr); }
.grid-3 { grid-template-columns: minmax(0, 1fr); }

.project-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.project-card:hover { transform: translateY(-3px); border-color: var(--line-strong); box-shadow: var(--shadow); }
.project-media {
  aspect-ratio: 16 / 10;
  background: var(--bg-tint);
  overflow: hidden;
}
.project-media img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s ease; }
.project-card:hover .project-media img { transform: scale(1.04); }
.project-media-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--muted);
  background: linear-gradient(150deg, var(--accent-soft), transparent);
}
.project-body { padding: 20px 22px 24px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.project-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.project-title { font-family: var(--font-display); font-size: 1.24rem; font-weight: 500; }
.project-summary { font-size: 14.5px; color: var(--ink-soft); flex: 1; }

.tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  white-space: nowrap;
}
.tag-accent { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.16s ease;
}
.chip:hover { border-color: var(--line-strong); }
.chip.is-on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

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

.skill-group + .skill-group { margin-top: 30px; }
.skill-group-title {
  font-size: 11.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
}
.skill { margin-bottom: 16px; }
.skill-top { display: flex; justify-content: space-between; gap: 12px; font-size: 14.5px; margin-bottom: 7px; }
.skill-top b { font-weight: 600; }
.skill-top span { color: var(--muted); font-size: 12.5px; }
.skill-bar { height: 5px; border-radius: 999px; background: var(--line); overflow: hidden; }
.skill-bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 45%, var(--ink)));
  width: 0;
  transition: width 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

/* --------------------------------- timeline -------------------------------- */

.timeline { position: relative; padding-left: 26px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 6px;
  bottom: 6px;
  width: 1px;
  background: var(--line-strong);
}
.tl-item { position: relative; padding-bottom: 28px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: '';
  position: absolute;
  left: -26px;
  top: 7px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
}
.tl-period { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.tl-title { font-family: var(--font-display); font-size: 1.15rem; margin-top: 4px; }
.tl-org { font-size: 14px; color: var(--accent); font-weight: 500; margin-top: 2px; }
.tl-desc { font-size: 14.5px; color: var(--ink-soft); margin-top: 8px; }

/* ---------------------------------- insights ------------------------------- */

.post-row {
  display: grid;
  gap: 6px;
  padding: 22px 4px;
  border-bottom: 1px solid var(--line);
  transition: padding-left 0.2s ease;
}
.post-row:first-child { border-top: 1px solid var(--line); }
.post-row:hover { padding-left: 10px; }
.post-date { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.post-title { font-family: var(--font-display); font-size: clamp(1.1rem, 2.1vw, 1.4rem); font-weight: 500; }
.post-excerpt { font-size: 14.5px; color: var(--ink-soft); max-width: 78ch; }
.post-row .tag-row { display: flex; flex-wrap: wrap; gap: 6px; }

.prose {
  font-size: 16.5px;
  line-height: 1.78;
  color: var(--ink-soft);
  max-width: 74ch;
}
.prose > * + * { margin-top: 1.1em; }
.prose h2 { font-family: var(--font-display); font-size: 1.55rem; margin-top: 1.9em; color: var(--ink); }
.prose h3 { font-family: var(--font-display); font-size: 1.25rem; margin-top: 1.6em; color: var(--ink); }
.prose strong { color: var(--ink); font-weight: 600; }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose ul li { list-style: disc; }
.prose ol li { list-style: decimal; }
.prose li + li { margin-top: 0.4em; }
.prose blockquote {
  border-left: 2px solid var(--accent);
  padding-left: 18px;
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--ink);
}
.prose code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--bg-tint);
  padding: 2px 6px;
  border-radius: 5px;
}
.prose pre {
  background: var(--bg-tint);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px;
  overflow-x: auto;
}
.prose img { border-radius: var(--radius-sm); margin-block: 1.4em; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin-block: 2em; }

.article-head { max-width: 74ch; }
.article-cover {
  margin-block: clamp(22px, 4vw, 36px);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  aspect-ratio: 16 / 8;
}
.article-cover img { width: 100%; height: 100%; object-fit: cover; }

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

.contact-grid { display: grid; gap: clamp(24px, 4vw, 48px); }

.field { display: flex; flex-direction: column; gap: 7px; }
.field > label {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.input, .textarea, .select {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { min-height: 140px; resize: vertical; line-height: 1.6; }
.form-grid { display: grid; gap: 16px; }
.form-note { font-size: 13px; color: var(--muted); }
.form-error { color: var(--danger); font-size: 13.5px; font-weight: 500; }
.form-ok { color: var(--ok); font-size: 13.5px; font-weight: 500; }

.contact-item { display: flex; gap: 14px; align-items: flex-start; padding-block: 16px; border-bottom: 1px solid var(--line); }
.contact-item:last-child { border-bottom: 0; }
.contact-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 15px;
}
.contact-label { font-size: 11.5px; letter-spacing: 0.13em; text-transform: uppercase; color: var(--muted); }
.contact-value { font-size: 15px; word-break: break-word; }
.contact-value:hover { color: var(--accent); }

.social-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.social-link {
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.16s ease;
}
.social-link:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ------------------------------- states / misc ---------------------------- */

.state {
  text-align: center;
  padding: clamp(38px, 7vw, 70px) 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.state p { color: var(--muted); font-size: 14.5px; }
.state-title { font-size: 15px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.state-error { border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.state-error .state-title { color: var(--danger); }
.state-loading { display: grid; place-items: center; gap: 14px; }

.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hero-skeleton { padding-block: clamp(20px, 6vw, 60px); }
.skel-lines { display: grid; gap: 10px; margin-top: 26px; max-width: 560px; }
.skel-lines span,
.skel-card {
  display: block;
  height: 12px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--bg-tint), var(--line), var(--bg-tint));
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.skel-lines span:nth-child(2) { width: 82%; }
.skel-lines span:nth-child(3) { width: 64%; }
.skel-card { height: 180px; border-radius: var(--radius); }
@keyframes shimmer {
  0% { background-position: 140% 0; }
  100% { background-position: -40% 0; }
}

.divider { height: 1px; background: var(--line); border: 0; margin-block: clamp(28px, 5vw, 52px); }

.pill-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
}

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

.site-footer {
  border-top: 1px solid var(--line);
  padding-block: clamp(28px, 4vw, 44px);
  background: var(--bg-tint);
}
.footer-inner { display: grid; gap: 18px; }
.footer-name { font-family: var(--font-display); font-size: 1.1rem; }
.footer-note { font-size: 13.5px; color: var(--muted); max-width: 46ch; }
.footer-links { display: flex; flex-wrap: wrap; gap: 18px; font-size: 13.5px; }
.footer-links a { color: var(--ink-soft); }
.footer-links a:hover { color: var(--accent); }
.footer-copy { font-size: 12.5px; color: var(--muted); }

/* ---------------------------------- toast --------------------------------- */

.toast-root {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 300;
  display: grid;
  gap: 8px;
  width: min(92vw, 420px);
}
.toast {
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: toast-in 0.22s ease;
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.toast-ok { background: #1f6b45; color: #fff; }
.toast-error { background: #8c2f2f; color: #fff; }
.toast.is-out { opacity: 0; transform: translateY(8px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------------------------------- modal --------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: rgba(8, 10, 14, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  overflow-y: auto;
}
.modal {
  width: 100%;
  max-width: 640px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  animation: modal-in 0.22s ease;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(18px); } }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 1.05rem; font-weight: 600; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 16px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 0 0 0 0;
}

/* ---------------------------------- admin --------------------------------- */

.admin-shell { max-width: 1040px; }
.admin-gate { max-width: 430px; margin: clamp(20px, 6vw, 60px) auto; }
.admin-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
}
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.tab {
  padding: 9px 15px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { background: var(--accent-soft); color: var(--ink); }
.tab.is-active { background: var(--ink); color: var(--bg); }

.admin-list { display: grid; gap: 10px; }
.admin-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.admin-row-main { flex: 1; min-width: 0; }
.admin-row-title { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-row-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-row-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.mini-btn {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 11px;
  font-size: 12.5px;
  cursor: pointer;
}
.mini-btn:hover { border-color: var(--ink); }
.mini-btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: var(--accent-soft);
  color: var(--accent);
}
.badge-draft { background: var(--bg-tint); color: var(--muted); }

.form-2col { display: grid; gap: 14px; }
.checkbox-row { display: flex; align-items: center; gap: 9px; font-size: 14px; }
.checkbox-row input { width: 17px; height: 17px; accent-color: var(--accent); }
.image-preview {
  margin-top: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  overflow: hidden;
  max-width: 260px;
  aspect-ratio: 16 / 10;
  background: var(--bg-tint);
}
.image-preview img { width: 100%; height: 100%; object-fit: cover; }
.group-title {
  font-size: 11.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 26px 0 12px;
}

/* -------------------------------- responsive ------------------------------ */

@media (min-width: 640px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid .field-full { grid-column: 1 / -1; }
  .footer-inner { grid-template-columns: 1fr auto; align-items: center; }
  .footer-copy { grid-column: 1 / -1; }
  .modal-overlay { align-items: center; padding: 24px; }
  .modal { border-radius: 18px; }
  .form-2col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-2col .field-full { grid-column: 1 / -1; }
}

@media (min-width: 900px) {
  .menu-btn { display: none; }
  .hero { grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .contact-grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); }
  .post-row { grid-template-columns: 150px minmax(0, 1fr); align-items: baseline; gap: 22px; }
  .post-row .post-main { display: grid; gap: 6px; }
}

@media (max-width: 899px) {
  .menu-btn { display: grid; }
  .nav {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 10px clamp(18px, 5vw, 48px) 18px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
    display: none;
  }
  body.nav-open .nav { display: flex; }
  .nav a { padding: 13px 12px; border-radius: 10px; font-size: 15.5px; }
  .nav a.is-active::after { display: none; }
  .nav a.is-active { background: var(--accent-soft); }
}

@media (min-width: 1024px) {
  .grid-3 { gap: 26px; }
  .view { padding-block: 64px 110px; }
}

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