@font-face {
  font-family: 'NaN SuperX Serif Text';
  src: url('fonts/NaNSuperXSerifTextVF.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@media (min-width: 921px) {
  .section-nav {
    display: flex;
    top: calc(env(safe-area-inset-top) + 1rem);
  }

  .section-menu {
    display: none;
  }

  :root {
    --frame-h: 400px;
  }
}

@font-face {
  font-family: 'NaN SuperX Serif Text';
  src: url('fonts/NaNSuperXSerifTextItalicVF.ttf') format('truetype');
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

:root {
  --blue: #adceff;
  --link: #d4e2ff;
  --bg: #eefbff;
  --text: #000000;
  --text-mid: #000000;
  --text-secondary: #000000;
  --text-tertiary: #000000;
  --border-subtle: rgba(255, 255, 255, 0.2);

  --font-serif: 'NaN SuperX Serif Text', Georgia, 'Times New Roman', serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Code', 'Fira Code', 'Courier New', monospace;

  --frame-w: 520px;
  --frame-h: 320px;
  --frame-w-px: var(--frame-w);
  --frame-h-px: var(--frame-h);
  --frame-h-max: 480px;
  --frame-h-max-px: var(--frame-h-max);
  --frame-border: 2px;
  --menu-border: 1px;

  --cursor-size: 36px;
}

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

button {
  cursor: pointer;
  border: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  font: inherit;
}

.haptic-proxy-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.haptic-proxy-switch {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  z-index: 2;
  cursor: inherit;
  pointer-events: auto;
  -webkit-appearance: auto;
  appearance: auto;
  background: transparent;
  touch-action: manipulation;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  font-synthesis: none;
  scroll-behavior: auto;
  overflow: hidden;
}

body {
  font-family: var(--font-serif);
  color: var(--text);
  min-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  text-transform: lowercase;
  line-height: 1.5;
  touch-action: pan-x pan-y pinch-zoom;
  zoom: 1;
  position: relative;
  font-feature-settings: 'ss05' 1; /* Enable stylistic set 5 for classic single-story 'a' */
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--bg);
  background-image: url('image/clouds.webp');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  will-change: transform;
  pointer-events: none;
}

#frame-wrapper,
.section-nav,
.section-menu {
  position: relative;
  z-index: 10;
}

#frame-wrapper {
  position: fixed;
  inset: 0;
  opacity: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4rem clamp(1.5rem, 4vw, 4rem);
  z-index: 10;
  pointer-events: none;
}

body.error-page #frame-wrapper {
  opacity: 1;
  animation: fadeIn 0.6s ease forwards;
}

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

#frame {
  position: relative;
  width: var(--frame-w);
  height: var(--frame-h);
  flex-shrink: 0;
  will-change: transform;
  transform-origin: 50% 50%;
}

#frame-border {
  position: absolute;
  inset: 0;
  border: var(--frame-border) solid var(--blue);
  pointer-events: none;
  z-index: 2;
}

#frame-content {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 1;
}

#frame-stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--frame-w-px, var(--frame-w));
  height: var(--frame-h-px, var(--frame-h));
  transform: translate(-50%, -50%);
}

#frame-label {
  position: absolute;
  top: -1px;
  left: 0;
  transform: translateY(-100%);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: #ffffff;
  letter-spacing: 0.01em;
  padding-bottom: 5px;
  white-space: nowrap;
  z-index: 30;
  user-select: none;
}

#frame-label span {
  display: inline-block;
  transition: opacity 0.2s ease;
}

#frame-cursor {
  position: absolute;
  width: var(--cursor-size);
  height: auto;
  z-index: 20;
  pointer-events: none;
  overflow: visible;
  transform-origin: 50% 50%;
}

.frame-section {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--section-w, 100%);
  height: var(--section-h, 100%);
  margin-top: calc(var(--section-h, 100%) / -2);
  margin-left: calc(var(--section-w, 100%) / -2);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1.8rem 2.7rem;
  opacity: 0;
  visibility: hidden;
  will-change: opacity, transform;
  pointer-events: none;
}

.frame-section.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#section-hero {
  align-items: center;
  justify-content: center;
  padding: 0.95rem;
  text-align: left;
}

#section-hero h1 {
  font-size: 3.45rem;
  font-weight: 400;
  line-height: 1.2;
  font-style: italic;
  letter-spacing: 0;
  color: var(--text);
}

#section-about {
  justify-content: center;
  gap: 1.25rem;
}

#section-about p {
  font-size: 1.22rem;
  line-height: 1.65;
  font-weight: 400;
  max-width: 540px;
  letter-spacing: 0;
}

#section-about p.lead {
  font-size: 1.38rem;
  line-height: 1.5;
}

#section-about p.secondary {
  color: var(--text-mid);
  font-size: 1.12rem;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  row-gap: 1.05rem;
  column-gap: calc(0.55rem + 8px);
  width: 100%;
  height: 100%;
  align-content: center;
}

.project-card {
  padding: 0;
  border: none;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  min-width: 0;
  transition: transform 0.22s ease;
  pointer-events: auto;
  cursor: default;
}

.project-card h3,
.project-card h3 a {
  font-family: var(--font-serif);
  font-size: 1.22rem;
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0;
  color: var(--link);
  text-decoration: none;
  transition: color 0.2s ease;
}

.project-card h3 .no-link {
  display: inline-block;
  width: fit-content;
}

.project-card h3 a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.12em;
}

.project-card .tag {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

.project-card p {
  font-size: 0.86rem;
  line-height: 1.42;
  color: var(--text-mid);
  max-width: 27ch;
}

@media (min-width: 921px) {
  #section-about,
  #section-apps,
  #section-websites,
  #section-products {
    padding-left: 2.4rem;
    padding-right: 2.4rem;
  }

  .project-grid {
    row-gap: calc(1.05rem + 20px);
    column-gap: calc(0.55rem + 16px);
  }

  #section-about {
    padding-right: calc(2.4rem - 8px);
  }

  #section-about p {
    max-width: none;
  }

  .project-card p {
    max-width: none;
  }
}

#section-products .product-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  row-gap: 1.4rem;
  column-gap: calc(0.6rem + 8px);
  width: 100%;
  align-content: center;
  height: 100%;
}

.product-card {
  padding: 0;
  border: none;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  min-width: 0;
  transition: transform 0.22s ease;
  pointer-events: auto;
  cursor: default;
}

.product-card h3,
.product-card h3 a {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0;
  color: var(--link);
  text-decoration: none;
  transition: color 0.2s ease;
}

.product-card h3 .no-link {
  display: inline-block;
  width: fit-content;
}

.product-card h3 a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.12em;
}

.product-card .tag {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

.product-card p {
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text-mid);
}

#section-contact {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1.4rem;
}

#section-contact p {
  font-size: 1.35rem;
  line-height: 1.35;
  max-width: 19rem;
  letter-spacing: 0;
}

#section-contact .copyright-note {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  line-height: 1;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  max-width: 56ch;
  margin-top: 0.55rem;
  opacity: 0.86;
}

#section-contact .copyright-note .copyright-tagline {
  display: inline-block;
  margin-top: 0.3rem;
  letter-spacing: 0.02em;
}

.contact-links {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 0.85rem;
  align-items: center;
}

.contact-links a {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-style: italic;
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.12em;
  letter-spacing: 0;
  transition: color 0.2s ease;
  pointer-events: auto;
  position: relative;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 4px;
}

@media (hover: hover) and (pointer: fine) {
  .contact-links a:hover {
    color: var(--text);
  }

  .project-card h3 a:hover,
  .product-card h3 a:hover {
    color: #000000 !important;
  }

  .project-card h3 .no-link:hover,
  .product-card h3 .no-link:hover {
    color: #000000 !important;
  }
}

.section-nav {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top) + 1rem);
  z-index: 30;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.85rem;
  transform: translateX(-50%);
  pointer-events: auto;
  font-family: 'Cascadia Code', 'Cascadia Mono', var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  text-transform: lowercase;
}

.section-nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: #ffffff;
  font-family: inherit;
  font-size: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  pointer-events: none;
  white-space: nowrap;
  flex-shrink: 0;
  font-weight: 500;
}

.section-nav-bullet {
  color: #ffffff;
  font-weight: 700;
}

@media (min-width: 921px) {
  .section-nav {
    font-size: 0.7rem;
    letter-spacing: 0.06em;
  }
}

.section-link {
  display: inline-flex;
  padding: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  border: 0;
  line-height: 1;
  letter-spacing: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.section-nav .section-link:first-of-type {
  margin-left: -4px;
}

.section-link.is-active {
  color: #ffffff;
  border-bottom-color: currentColor;
  font-weight: 500;
}

@media (hover: hover) and (pointer: fine) {
  .section-link:hover {
    color: #ffffff;
  }
}

.section-menu {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 1rem);
  right: 1rem;
  z-index: 35;
  display: none;
  align-items: center;
  justify-content: flex-end;
  pointer-events: auto;
}

body.nav-hidden .section-nav {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.section-menu-toggle {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: var(--menu-border) solid var(--blue);
  border-radius: 0;
  color: var(--blue);
  background: transparent;
}

.section-menu-icon {
  width: 16px;
  height: 12px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.section-menu-icon span {
  display: block;
  width: 100%;
  height: var(--menu-border);
  background: currentColor;
  border-radius: 999px;
  transition: transform 220ms ease, opacity 220ms ease;
  transform-origin: center;
}

.section-menu-toggle[aria-expanded="true"] .section-menu-icon {
  justify-content: center;
}

.section-menu-toggle[aria-expanded="true"] .section-menu-icon span:nth-child(1) {
  position: absolute;
  transform: rotate(45deg) scaleX(1.08);
}

.section-menu-toggle[aria-expanded="true"] .section-menu-icon span:nth-child(2) {
  opacity: 0;
}

.section-menu-toggle[aria-expanded="true"] .section-menu-icon span:nth-child(3) {
  position: absolute;
  transform: rotate(-45deg) scaleX(1.08);
}

.section-nav-mobile {
  position: fixed;
  right: 1rem;
  top: calc(env(safe-area-inset-top) + 3.5rem);
  width: min(10.5rem, calc(100vw - 2rem));
  display: none;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem 0.6rem;
  border: var(--menu-border) solid var(--blue);
  border-radius: 0;
  background: transparent;
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  transition: max-height 240ms ease, opacity 200ms ease, transform 200ms ease;
  transform: translateY(-6px);
  z-index: 34;
}

.section-nav-mobile.is-open {
  max-height: 16rem;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.section-nav-mobile .section-link {
  color: var(--text);
  border-bottom-color: transparent;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  justify-content: flex-start;
  padding: 0.2rem 0;
}

.section-nav-mobile .section-link.is-active {
  color: var(--link);
}

@media (max-width: 920px) {
  :root {
    --frame-w: 420px;
    --frame-h: 340px;
  }

  #section-hero h1 {
    font-size: 3rem;
  }

  #section-about p.lead {
    font-size: 1.2rem;
  }

  .frame-section {
    padding: 1.7rem 2.15rem;
  }
}

@media (max-width: 640px) {
  :root {
    --frame-w: 90vw;
    --frame-h: 68vw;
    --cursor-size: 32px;
  }

  #frame-wrapper {
    padding: calc(env(safe-area-inset-top) + 0.9rem) 1rem calc(env(safe-area-inset-bottom) + 1.25rem);
  }

  #frame-cursor {
    display: block;
    filter: drop-shadow(0 1px 5px rgba(35, 74, 255, 0.14));
  }

  #section-hero h1 {
    font-size: 2.05rem;
    line-height: 1.14;
    white-space: nowrap;
  }

  #section-hero {
    padding: 0.7rem;
  }

  #section-about p {
    font-size: 1.08rem;
    line-height: 1.56;
  }

  #section-about p.lead, i {
    font-size: 1.18rem;
    line-height: 1.45;
    font-weight: 500;
  }

  #section-about,
  #section-contact {
    padding-block: calc(1.2rem + 60px);
  }

  .frame-section {
    padding: calc(1.2rem + 16px) 1.35rem;
  }

  ul,
  ol {
    margin-block: 1.5rem;
    font-size: 1.05rem;
  }

  .project-grid {
    grid-template-columns: 1fr;
    gap: 1.28rem;
    align-content: center;
  }

  .project-card {
    padding: 0.14rem 0;
    gap: 0.34rem;
  }

  .project-card h3,
  .project-card h3 a {
    font-size: 1.08rem;
    line-height: 1.12;
  }

  .project-card .tag,
  .product-card .tag {
    font-size: 0.68rem;
    line-height: 1.45;
  }

  .project-card p {
    font-size: 0.82rem;
    line-height: 1.42;
    max-width: none;
  }

  #section-products .product-grid {
    grid-template-columns: 1fr;
    gap: 1.34rem;
    align-content: center;
  }

  .product-card {
    padding: 0.22rem 0;
    gap: 0.34rem;
  }

  .product-card h3,
  .product-card h3 a {
    font-size: 1.1rem;
    line-height: 1.12;
  }

  .product-card p {
    font-size: 0.84rem;
    line-height: 1.42;
  }

  #section-contact p {
    font-size: 1.05rem;
    line-height: 1.38;
  }

  #section-contact .copyright-note {
    font-size: 0.66rem;
    line-height: 1.55;
  }
  
  #section-contact .copyright-note .copyright-tagline {
    margin-top: 0.4rem;
  }

  .contact-links {
    flex-direction: column;
    gap: 0.56rem;
  }

  .contact-links a,
  .project-card h3 a,
  .product-card h3 a {
    min-height: 2rem;
    display: inline-flex;
    align-items: center;
  }

  #frame-label {
    font-size: 0.65rem;
  }

  .section-nav {
    display: none;
  }

  .section-menu {
    display: inline-flex;
  }

  .section-nav-mobile {
    display: flex;
  }
}

@media (max-width: 360px) {
  #section-hero h1 {
    font-size: 1.84rem;
  }

  #section-hero {
    padding: 0.6rem;
  }

  #section-about,
  #section-contact {
    padding-block: calc(1rem + 60px);
  }

  .frame-section {
    padding: calc(1rem + 16px) 1.1rem;
  }

  .project-grid,
  #section-products .product-grid {
    gap: 1.05rem;
  }

  .project-card p,
  .product-card p {
    font-size: 0.78rem;
    line-height: 1.36;
  }
  
  #section-contact .copyright-note {
    font-size: 0.62rem;
  }
}

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

.error-content {
  position: absolute;
  top: 50%;
  left: 50%;
  width: calc(100% - 4rem);
  height: calc(100% - 4rem);
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0;
  gap: 1.5rem;
}

.error-content h1 {
  font-size: 3.2rem;
  font-weight: 400;
  line-height: 1.2;
  color: var(--text);
  letter-spacing: 0;
}

.error-content h1 i {
  font-style: italic;
}

.error-message {
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--text-mid);
  max-width: 32ch;
  letter-spacing: 0;
}

.error-actions {
  display: flex;
  flex-direction: row;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  pointer-events: auto;
}

.error-actions a {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-style: italic;
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.12em;
  letter-spacing: 0;
  transition: color 0.2s ease;
  padding: 0.5rem 0.75rem;
  min-height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.error-actions a:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 4px;
}

@media (hover: hover) and (pointer: fine) {
  .error-actions a:hover {
    color: var(--text);
  }
}

.error-code {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  margin-top: 0.5rem;
  opacity: 0.8;
}

.error-code span {
  font-weight: 600;
}

@media (min-width: 921px) {
  :root {
    --frame-h: 400px;
  }
}

@media (max-width: 920px) {
  .error-content h1 {
    font-size: 2.8rem;
  }

  .error-message {
    font-size: 1rem;
  }

  .error-content {
    width: calc(100% - 3.5rem);
    height: calc(100% - 3.5rem);
    gap: 1.3rem;
  }
}

@media (max-width: 640px) {
  .error-content {
    width: calc(100% - 3rem);
    height: calc(100% - 3rem);
    gap: 1.2rem;
  }

  .error-content h1 {
    font-size: 2rem;
    line-height: 1.15;
  }

  .error-message {
    font-size: 0.95rem;
    line-height: 1.5;
    max-width: 28ch;
  }

  .error-actions {
    flex-direction: column;
    gap: 0.6rem;
  }

  .error-actions a {
    font-size: 0.95rem;
    min-height: 2.2rem;
  }

  .error-code {
    font-size: 0.65rem;
    margin-top: 0.3rem;
  }
}

@media (max-width: 360px) {
  .error-content h1 {
    font-size: 1.75rem;
  }

  .error-content {
    width: calc(100% - 2.4rem);
    height: calc(100% - 2.4rem);
    gap: 1rem;
  }

  .error-message {
    font-size: 0.88rem;
  }

  .error-actions a {
    font-size: 0.88rem;
  }

  .error-code {
    font-size: 0.6rem;
  }
}
