:root {
  color-scheme: light;
  --page-bg: #fafafa;
  --surface: #f1f1f1;
  --card-bg: #fff;
  --text-main: #292929;
  --text-muted: #666;
  --line: #dedede;
  --accent: #555;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --page-bg: #202020;
  --surface: #292929;
  --card-bg: #252525;
  --text-main: #eee;
  --text-muted: #b0b0b0;
  --line: #3d3d3d;
  --accent: #ccc;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 110px; }
body { margin: 0; background: var(--page-bg); color: var(--text-main); font-family: "IBM Plex Mono", monospace; }
h1, h2, h3, p, ul { margin: 0; }
a { color: inherit; text-decoration: none; transition: color .3s; }
a:hover { color: var(--accent); }
svg { display: block; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 5px; }
.accent-text { color: var(--accent); }

.site-header { position: fixed; inset: 0 0 auto; z-index: 50; background: var(--page-bg); transition: background .3s, box-shadow .3s; }
.site-header.is-scrolled { background: color-mix(in srgb, var(--page-bg) 5%, transparent); backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 1px 0 var(--line); }
.main-nav { display: flex; align-items: center; gap: 24px; width: 100%; padding: 16px 180px 16px 96px; }
.nav-logo { flex-shrink: 0; font-size: 18px; font-weight: 700; line-height: 1; }
.nav-toggle { display: none; }
.nav-list { display: flex; flex: 1; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px 32px; padding: 0; list-style: none; }
.nav-link { font-weight: 500; }
.nav-link, .footer-nav-link { position: relative; display: inline-block; overflow: hidden; padding-block: 8px; }
.nav-link::after, .footer-nav-link::after { content: ""; position: absolute; inset: auto 0 2px; height: 2px; background: var(--accent); transform: translateX(-105%); }
.nav-link:hover::after, .nav-link:focus-visible::after, .footer-nav-link:hover::after, .footer-nav-link:focus-visible::after { animation: navUnderline .3s ease-out forwards; }
@keyframes navUnderline {
  0% { transform: translateX(-105%); }
  100% { transform: translateX(0); }
}

.theme-toggle { position: fixed; top: 12px; right: 20px; z-index: 60; width: 76px; height: 40px; padding: 0; border: 1px solid #aaa; border-radius: 999px; background: #b5b5b5; color: #fff; cursor: pointer; transition: background .25s, border-color .25s; }
.theme-thumb { position: absolute; top: 5px; left: 5px; width: 28px; height: 28px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px #0002; transition: transform .25s ease; }
.theme-sun, .theme-moon { position: absolute; top: 9px; width: 20px; height: 20px; transition: opacity .2s; }
.theme-sun { right: 8px; }
.theme-moon { left: 8px; opacity: 0; }
html[data-theme="dark"] .theme-toggle { background: #333; border-color: #444; }
html .theme-toggle.is-scrolled { background: color-mix(in srgb, var(--page-bg) 15%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-color: var(--line); }
html[data-theme="dark"] .theme-thumb { transform: translateX(36px); }
html[data-theme="dark"] .theme-sun { opacity: 0; }
html[data-theme="dark"] .theme-moon { opacity: 1; }

.hero { position: relative; isolation: isolate; overflow: hidden; padding-block: 96px; }
.hero-background, .hero-pattern { position: absolute; inset: 0; z-index: -1; }
.hero-pattern { width: 100%; height: 100%; stroke: var(--line); opacity: .35; mask-image: radial-gradient(100% 100% at top right, white, transparent); }
.hero-pattern text { fill: var(--accent); }
.hero-content { display: flex; align-items: center; gap: 40px; height: 100%; margin: auto; padding: 32px; }
.hero-intro { flex: 1; min-width: 0; }
.hero-circuit { display: none; position: absolute; top: 50%; right: -48px; z-index: -1; width: clamp(300px, 27vw, 390px); height: auto; transform: translateY(-50%); opacity: .8; user-select: none; pointer-events: none; mask-image: linear-gradient(to bottom, transparent, #000 15%, #000 85%, transparent); }
html[data-theme="dark"] .hero-circuit { filter: invert(1); opacity: .7; }
.hero-title { margin-top: 24px; font-size: 36px; line-height: 1.1; letter-spacing: -.025em; text-wrap: pretty; }
.hero-subtitle { margin-top: 16px; color: var(--text-muted); font-size: 16px; font-weight: 500; text-wrap: pretty; }
.hero-socials { position: absolute; inset: auto 0 0; display: flex; gap: 16px; padding: 32px; }
.hero-icon, .social-icon { width: 24px; height: 24px; }
.social-link { display: inline-flex; }
.hero-title, .hero-subtitle, .hero-socials { animation: fadeIn .8s ease-out both; }
.hero-title { animation-delay: .2s; }
.hero-subtitle { animation-delay: .4s; }
.hero-socials { animation-delay: .6s; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}


.portfolio-section { padding: 32px; }
.section-grid { display: grid; gap: 32px; align-items: start; }
.section-title { font-size: 30px; line-height: 1.2; }
.section-line { width: 75px; height: 5px; margin-top: 8px; border-radius: 999px; background: var(--accent); }
.section-content { color: var(--text-muted); font-size: 18px; line-height: 1.625; }
.section-content > * + * { margin-top: 32px; }
.project-card { padding: 0; }
.card-title { color: var(--text-main); font-size: 20px; line-height: 1.4; }
.card-description { margin-top: 16px; }
.project-status { margin-top: 8px; color: var(--text-muted); font-size: 14px; line-height: 1.7; }
.portfolio-skills { padding-left: 1.3em; list-style: disc; }
.portfolio-skills li + li { margin-top: 16px; }
.portfolio-contact { display: flex; flex-direction: column; align-items: flex-start; gap: 24px; }
.portfolio-contact a { overflow-wrap: anywhere; text-decoration: underline; text-underline-offset: 5px; }

.site-footer { position: relative; background: var(--surface); border-top: 1px solid var(--line); }
.footer-container { max-width: 72rem; margin: auto; padding: 48px 24px; }
.footer-layout { display: flex; flex-direction: column; gap: 32px; }
.footer-brand { display: flex; flex-direction: column; gap: 16px; }
.footer-socials { display: flex; gap: 24px; }
.footer-link { color: var(--text-muted); }
.footer-details { display: flex; flex-direction: column; gap: 16px; }
.footer-nav { display: none; gap: 32px; }
.footer-nav-link, .copyright { color: var(--text-muted); font-size: 14px; }
.copyright a { text-decoration: underline; text-underline-offset: 4px; }
.footer-decoration { position: absolute; inset: 0; z-index: -1; overflow: hidden; }
.footer-pattern { position: absolute; inset: auto 0 0; width: 100%; height: 96px; color: var(--line); }

.rights-page { max-width: 56rem; margin: auto; padding: 120px 32px 64px; line-height: 1.7; }
.rights-page h1 { margin: 32px 0; font-size: 30px; line-height: 1.2; }
.rights-page section + section { margin-top: 32px; }
.rights-page h2 { margin-bottom: 12px; font-size: 22px; }
.rights-page p + p { margin-top: 16px; }
.rights-page a { text-decoration: underline; text-underline-offset: 4px; }
.credits-ascii { width: fit-content; max-width: 100%; margin: clamp(240px, 45svh, 480px) auto 0; color: var(--text-muted); opacity: .4; font: clamp(7px, 1.8vw, 10px)/1.15 monospace; white-space: pre; overflow-x: auto; }
.license-text { padding: 24px; overflow-wrap: anywhere; white-space: pre-wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; font: inherit; font-size: 14px; }

@media (min-width: 640px) {
  .hero-content, .hero-socials, .portfolio-section { padding: 48px; }
  .hero-title { margin-top: 32px; font-size: 48px; }
  .hero-subtitle { margin-top: 24px; font-size: 18px; }
  .hero-socials { gap: 24px; }
  .hero-icon { width: 28px; height: 28px; }
  .section-title { font-size: 36px; }
  .card-title { font-size: 24px; }
}
@media (min-width: 768px) {
  .hero { min-height: 100svh; }
  .hero-content { min-height: calc(100svh - 192px); }
  .hero-content, .hero-socials { padding: 96px; }
  .hero-title { margin-top: 40px; font-size: 60px; }
  .hero-subtitle { margin-top: 32px; font-size: 20px; line-height: 32px; }
  .hero-socials { gap: 32px; }
  .hero-icon { width: 32px; height: 32px; }
  .portfolio-section { padding: 64px; }
  .section-title { font-size: 48px; line-height: 1; }
  .footer-layout { flex-direction: row; align-items: center; justify-content: space-between; }
  .footer-nav { display: flex; }
}
@media (min-width: 1024px) {
  .hero-intro { max-width: calc(100% - 160px); }
  .hero-circuit { display: block; }
  .hero-title { font-size: 96px; }
  .portfolio-section { padding: 96px; }
  .section-grid { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 64px; }
  .section-heading { grid-column: span 4; }
  .section-content { grid-column: span 8; }
  .footer-container { padding-inline: 32px; }
}
@media (max-width: 767px) {
  html { scroll-padding-top: 96px; }
  .main-nav { flex-wrap: wrap; gap: 0 16px; min-height: 80px; padding: 18px 24px; }
  .nav-logo { display: inline-flex; align-items: center; min-height: 44px; }
  .js .nav-toggle { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; width: 44px; height: 44px; margin-left: auto; margin-right: 96px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--text-main); cursor: pointer; }
  .nav-toggle span { flex-shrink: 0; width: 18px; height: 2px; background: currentColor; transition: transform .2s; }
  .menu-open .nav-toggle span:first-child { transform: translateY(4px) rotate(45deg); }
  .menu-open .nav-toggle span:last-child { transform: translateY(-4px) rotate(-45deg); }
  .nav-list { flex: 0 0 100%; flex-direction: column; align-items: stretch; gap: 0; max-height: calc(100svh - 100px); overflow-y: auto; margin-top: 16px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 16px; }
  .js .nav-list { display: none; }
  .menu-open .nav-list { display: flex; }
  .site-header.menu-open { background: color-mix(in srgb, var(--page-bg) 96%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 1px 0 var(--line); }
  .nav-link { display: block; padding: 12px 0; }
  .nav-link::after { width: 48px; }
  .theme-toggle { top: 24px; right: 24px; width: 60px; height: 32px; }
  .theme-toggle::before { content: ""; position: absolute; inset: -6px; }
  .theme-thumb { top: 4px; left: 4px; width: 22px; height: 22px; }
  .theme-sun, .theme-moon { top: 7px; width: 16px; height: 16px; }
  .theme-sun { right: 6px; }
  .theme-moon { left: 6px; }
  html[data-theme="dark"] .theme-thumb { transform: translateX(28px); }
  .hero { display: flex; flex-direction: column; min-height: 0; padding: 136px 24px 48px; }
  .hero-content { min-height: 0; height: auto; margin: 0; padding: 0; }
  .hero-title { margin-top: 0; font-size: clamp(36px, 10.5vw, 56px); line-height: 1.15; }
  .hero-subtitle { margin-top: 20px; font-size: 16px; line-height: 1.6; }
  .hero-circuit { display: block; top: 60%; right: -120px; width: 190px; opacity: .2; }
  html[data-theme="dark"] .hero-circuit { opacity: .2; }
  .hero-socials { position: static; gap: 12px; margin-left: -10px; padding: 24px 0 0; }
  .social-link, .footer-link { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; }
  .hero-icon { width: 24px; height: 24px; }
  .portfolio-section { padding: 40px 24px; }
  .section-grid { gap: 24px; }
  .section-title { font-size: 28px; }
  .section-line { width: 56px; height: 3px; }
  .section-content { min-width: 0; font-size: 16px; line-height: 1.75; overflow-wrap: anywhere; }
  .section-content > * + * { margin-top: 28px; }
  .card-title { font-size: 18px; line-height: 1.5; }
  .card-description { margin-top: 12px; }
  .portfolio-contact { gap: 16px; }
  .portfolio-contact a { display: inline-flex; align-items: center; min-height: 44px; }
  .footer-container { padding: 32px 24px; }
  .footer-layout { gap: 20px; }
  .footer-socials { gap: 12px; margin-left: -10px; }
  .copyright { line-height: 1.8; }
  .rights-page { padding: 96px 24px 48px; overflow-wrap: anywhere; }
  .rights-page h1 { font-size: 28px; }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .main-nav { padding-right: 116px; }
  .nav-list { gap: 8px 16px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .nav-link:hover::after, .nav-link:focus-visible::after, .footer-nav-link:hover::after, .footer-nav-link:focus-visible::after { transform: scaleX(1); }
}
