:root {
  --color-bg: #f3f2f2;
  --color-text: #201e1d;
  --color-accent: #0088b0;
  --accent-hover: #1186ac;
  --link: #006786;
  --ink-2: color-mix(in srgb, #201e1d 64%, transparent);
  --rule: color-mix(in srgb, #201e1d 13%, transparent);
}
:root[data-theme="dark"] {
  --color-bg: #1b1919;
  --color-text: #eae7e7;
  --color-accent: #62c5ee;
  --accent-hover: #99e0ff;
  --link: #99e0ff;
  --ink-2: color-mix(in srgb, #eae7e7 66%, transparent);
  --rule: color-mix(in srgb, #eae7e7 16%, transparent);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #1b1919;
    --color-text: #eae7e7;
    --color-accent: #62c5ee;
    --accent-hover: #99e0ff;
    --link: #99e0ff;
    --ink-2: color-mix(in srgb, #eae7e7 66%, transparent);
    --rule: color-mix(in srgb, #eae7e7 16%, transparent);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: 'Familjen Grotesk', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color-scheme: light dark;
}
a { color: var(--link); text-underline-offset: 3px; }
a:hover { color: var(--color-accent); }
.mono { font-family: 'Fragment Mono', ui-monospace, monospace; }

#app {
  container-type: inline-size;
  position: relative;
  min-height: 100vh;
}

/* header */
#site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--color-bg);
}
.bar-row {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: clamp(14px, 2.4cqi, 32px);
  padding: 16px clamp(20px, 5cqi, 64px);
}
.brand {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
  margin-right: auto;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.brand #idx-label { font-weight: 400; font-size: 11px; color: var(--ink-2); }
nav[aria-label="Sections"] { display: flex; gap: clamp(12px, 2cqi, 28px); font-size: 14px; }
.nav-link {
  text-decoration: none;
  color: var(--ink-2);
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 1px;
  background-repeat: no-repeat;
  background-position: 0 100%;
  transition: background-size .4s cubic-bezier(.2,.7,0,1), color .2s;
  padding-bottom: 2px;
}
.nav-link:hover { background-size: 100% 1px; color: var(--color-text); }
.nav-link.active { color: var(--color-text); background-size: 100% 1px; }

#theme-toggle {
  width: 32px; height: 32px;
  display: grid; place-items: center; flex: none;
  color: var(--color-text);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 50%;
  cursor: pointer; padding: 0;
  transition: border-color .2s, color .2s;
}
#theme-toggle:hover { border-color: var(--color-accent); color: var(--color-accent); }
#theme-toggle svg { transition: transform .6s cubic-bezier(.2,.7,0,1); }
:root[data-theme="dark"] #theme-toggle svg { transform: rotate(180deg); }

.progress-track { height: 1px; background: var(--rule); }
#progress-bar { height: 1px; background: var(--color-accent); transform-origin: 0 50%; transform: scaleX(0); }

/* main layout */
main, footer { max-width: 1200px; margin: 0 auto; padding: 0 clamp(20px, 5cqi, 64px); }

section[data-sec] { display: block; }
.row-section {
  display: flex;
  flex-wrap: wrap;
  gap: 20px clamp(24px, 4cqi, 56px);
  padding-top: clamp(112px, 13cqi, 176px);
}
.section-index {
  flex: 0 1 24%;
  min-width: 160px;
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-family: 'Fragment Mono', ui-monospace, monospace;
  font-size: 12px;
  color: var(--ink-2);
}
.section-index .idx-no { color: var(--color-accent); }
.section-index .idx-name { color: var(--color-text); }
.section-body { flex: 1 1 480px; }

/* hero */
.badge {
  display: flex; align-items: center; gap: 10px;
  font-family: 'Fragment Mono', ui-monospace, monospace;
  font-size: 12px; color: var(--ink-2);
}
.pulse-wrap { position: relative; width: 7px; height: 7px; flex: none; }
.pulse-wrap span { position: absolute; inset: 0; border-radius: 50%; background: var(--color-accent); }
#pulse-dot { animation: pulse 2s cubic-bezier(.2,.7,0,1) infinite; }
@keyframes pulse { from { transform: scale(1); opacity: .6; } to { transform: scale(3); opacity: 0; } }

.hero-h1 {
  margin: 28px 0 0;
  font-size: clamp(32px, 4.3cqi, 56px);
  line-height: 1.15;
  letter-spacing: -0.028em;
  font-weight: 600;
  max-width: 22ch;
}
.mask-line { display: block; overflow: hidden; }
.mask-line > span { display: block; }
.rot-line { height: 1.15em; color: var(--color-accent); }
#rotator {
  display: block;
  animation: rotator 8.4s cubic-bezier(.65,0,.35,1) infinite 1.4s;
}
#rotator span { display: block; height: 1.15em; }
@keyframes rotator {
  0%, 28% { transform: translateY(0); }
  34%, 61% { transform: translateY(-1.15em); }
  67%, 94% { transform: translateY(-2.3em); }
  100% { transform: translateY(-3.45em); }
}

.hero-p { margin: 32px 0 0; max-width: 46ch; font-size: 18px; line-height: 1.6; color: var(--ink-2); }
.hero-links { display: flex; flex-wrap: wrap; gap: 12px 28px; margin-top: 36px; font-size: 16px; }
.link-underline {
  display: flex; gap: 6px; align-items: baseline;
  text-decoration: none; color: var(--color-text);
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 1px; background-repeat: no-repeat; background-position: 0 100%;
  transition: background-size .45s cubic-bezier(.2,.7,0,1), color .2s;
  padding-bottom: 2px;
}
.link-underline:hover { background-size: 100% 1px; color: var(--color-accent); }

/* headings */
h1, h2 { font-family: 'Familjen Grotesk', system-ui, sans-serif; font-weight: 600; margin: 0; }
h2 { font-size: clamp(24px, 2.4cqi, 32px); line-height: 1.2; letter-spacing: -0.02em; max-width: 26ch; margin-bottom: 20px; }
.section-body > p { margin: 0; max-width: 62ch; font-size: 17px; line-height: 1.65; color: var(--ink-2); }

.hr-anim { height: 1px; background: var(--rule); transform-origin: 0 50%; }

/* work list */
#work-list-wrap { position: relative; }
#work-list { list-style: none; margin: 0; padding: 0; }
.work-row {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 24px;
  padding: 20px 0; color: var(--color-text); text-decoration: none;
  transition: opacity .3s;
}
#work-list li.dim .work-row { opacity: 0.4; }
.work-name { flex: 1 1 200px; display: flex; gap: 16px; align-items: baseline; }
.work-name .no { font-size: 11px; color: var(--ink-2); }
.work-name .name {
  font-size: 19px; font-weight: 600; letter-spacing: -0.01em;
  display: inline-block; transition: transform .45s cubic-bezier(.2,.7,0,1);
}
#work-list li:hover .work-name .name { transform: translateX(6px); }
.work-desc { flex: 2 1 260px; font-size: 15px; line-height: 1.5; color: var(--ink-2); }
.work-meta {
  flex: 0 0 auto; display: flex; gap: 14px; align-items: baseline; margin-left: auto;
  font-size: 11px; color: var(--ink-2);
}
.work-meta .year { min-width: 6ch; text-align: right; color: var(--color-text); }
.work-meta .arrow {
  display: inline-block; width: 12px; color: var(--color-accent);
  transition: transform .4s cubic-bezier(.2,.7,0,1), opacity .25s;
  transform: translateX(-6px); opacity: 0;
}
#work-list li:hover .work-meta .arrow { transform: none; opacity: 1; }

#cursor-tip {
  position: absolute; left: 0; top: 0; pointer-events: none; z-index: 2;
  will-change: transform; opacity: 0; transform: scale(.85);
  transition: opacity .2s, transform .3s cubic-bezier(.2,.7,0,1);
}
#cursor-tip span {
  display: block; padding: 6px 10px; border-radius: 2px;
  background: var(--color-text); color: var(--color-bg);
  font-family: 'Fragment Mono', ui-monospace, monospace; font-size: 11px; white-space: nowrap;
}

/* skills */
.skills-grid { display: flex; flex-wrap: wrap; gap: 36px clamp(24px, 4cqi, 56px); }
.skill-group { flex: 1 1 150px; }
.skill-head {
  display: flex; justify-content: space-between;
  font-family: 'Fragment Mono', ui-monospace, monospace; font-size: 11px; color: var(--ink-2);
  padding-bottom: 10px;
}
.skill-head .name { color: var(--color-text); }
.skill-group .hr-anim { margin-bottom: 12px; }
.skill-group ul { list-style: none; margin: 0; padding: 0; font-size: 16px; line-height: 1.9; }

/* contact */
.contact-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 20px; }
.btn-cta {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: 2px;
  background: var(--color-accent); color: var(--color-bg);
  text-decoration: none; font-size: 16px; font-weight: 600;
  transition: background .2s;
}
.btn-cta:hover { background: var(--accent-hover); color: var(--color-bg); }
.cta-arrow { display: inline-block; font-weight: 400; transition: transform .4s cubic-bezier(.2,.7,0,1); }
.btn-cta:hover .cta-arrow { transform: translateX(4px); }

#copy-btn {
  font-family: 'Fragment Mono', ui-monospace, monospace; font-size: 12px; color: var(--color-text);
  background: transparent; border: 1px solid var(--rule); border-radius: 2px;
  padding: 0 12px; min-height: 44px; cursor: pointer;
  display: flex; align-items: center; gap: 8px; transition: border-color .2s;
}
#copy-btn:hover { border-color: var(--color-accent); }
.copy-window { display: block; overflow: hidden; height: 1.4em; line-height: 1.4em; }
#copy-inner { display: block; transition: transform .45s cubic-bezier(.2,.7,0,1); }
#copy-inner span { display: block; }
#copy-inner .copied { color: var(--color-accent); }
#copy-btn.copied #copy-inner { transform: translateY(-50%); }

/* footer */
footer { padding: 0 clamp(20px, 5cqi, 64px); }
.footer-row {
  display: flex; flex-wrap: wrap; gap: 8px 28px; justify-content: space-between;
  padding: 20px 0 28px; font-size: 11px; color: var(--ink-2);
}
.clock { display: flex; gap: 6px; }
.clock-text { color: var(--color-text); }
#clock-colon { display: inline-block; animation: blink 2s steps(1) infinite; }
@keyframes blink { 0%, 50% { opacity: 1; } 55%, 95% { opacity: .2; } 100% { opacity: 1; } }
.footer-top { color: var(--ink-2); text-decoration: none; transition: color .2s; }
.footer-top:hover { color: var(--color-accent); }

/* scroll reveal */
[data-r] { will-change: transform, opacity; }
[data-r="mask"] { transform: translateY(110%); }
[data-r="mask"].in { transition: transform .76s cubic-bezier(.16,1,.3,1); transform: none; }
[data-r="row"] { opacity: 0; transform: translateY(10px); }
[data-r="row"].in { transition: opacity .56s cubic-bezier(.2,.7,0,1), transform .56s cubic-bezier(.2,.7,0,1); opacity: 1; transform: none; }
[data-r="slide"] { opacity: 0; transform: translateX(-12px); }
[data-r="slide"].in { transition: opacity .62s cubic-bezier(.16,1,.3,1), transform .62s cubic-bezier(.16,1,.3,1); opacity: 1; transform: none; }
[data-r="rule"] { transform: scaleX(0); }
[data-r="rule"].in { transition: transform 1.1s cubic-bezier(.7,0,.2,1); transform: none; }
[data-r="fade"] { opacity: 0; }
[data-r="fade"].in { transition: opacity .48s linear; opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  [data-r] { opacity: 1 !important; transform: none !important; transition: none !important; }
  #rotator, #pulse-dot, #clock-colon { animation: none !important; }
}
