/* ==========================================================================
   SakageNoAn — base styles
   ========================================================================== */

:root {
  --bg: #09090b;
  --bg-elevated: #0d0d10;
  --bg-card: #111116;
  --bg-card-hover: #16161d;

  --text: #f5f5f7;
  --text-muted: #a1a1aa;
  --text-subtle: #8a8a94;

  --accent: #8b5cf6;
  --accent-strong: #7c3aed;
  --accent-indigo: #6366f1;
  --accent-text: #b4a0fb;

  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  --radius-card: 20px;
  --radius-button: 999px;

  --container: 1180px;
  --gutter: 20px;
  --header-height: 64px;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --duration: 300ms;

  --font-sans: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI",
    Meiryo, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  color-scheme: dark;
}

@media (min-width: 768px) {
  :root {
    --gutter: 32px;
  }
}

/* Reset ------------------------------------------------------------------ */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-height) + 16px);
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-break: strict;
  word-break: auto-phrase;
}

main {
  flex: 1;
}

h1,
h2,
h3,
h4,
p,
ul {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg {
  display: block;
  max-width: 100%;
}

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

::selection {
  background: rgba(139, 92, 246, 0.4);
  color: var(--text);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  transform: translateY(-200%);
}

.skip-link:focus-visible {
  transform: none;
}

.container {
  width: 100%;
  max-width: calc(var(--container) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Header ----------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(9, 9, 11, 0.78);
  border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  backdrop-filter: saturate(140%) blur(12px);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--header-height);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-weight: 700;
  font-size: 1.0625rem;
  letter-spacing: -0.01em;
}

.brand__mark {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.site-nav__list {
  display: flex;
  align-items: center;
  gap: 4px;
}

.site-nav__link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: 12px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.9375rem;
  transition: color var(--duration) var(--ease), background-color var(--duration) var(--ease);
}

.site-nav__link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.site-nav__link[aria-current="page"] {
  color: var(--text);
}

/* Language switch: plain links, no JS. Current language is shown but not linked. */
.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 8px;
  padding: 2px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  line-height: 1;
}

.lang-switch__item {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 26px;
  padding-inline: 8px;
  border-radius: 999px;
  color: var(--text-muted);
  transition: color var(--duration) var(--ease), background-color var(--duration) var(--ease);
}

.lang-switch__item--current {
  background: rgba(139, 92, 246, 0.2);
  color: var(--text);
}

a.lang-switch__item:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

/* keep a 44px tap target without enlarging the pill */
a.lang-switch__item::after {
  content: "";
  position: absolute;
  inset: -9px -4px;
}

/* Mobile: only the link to the other language, e.g. "EN" */
@media (max-width: 639px) {
  .lang-switch {
    margin-left: 4px;
  }

  .lang-switch__item--current {
    display: none;
  }
}

/* Narrow phones (< 390px): tighten the nav so brand + Projects + About + EN fit */
@media (max-width: 389px) {
  .site-header__inner {
    gap: 8px;
    padding-inline: 16px;
  }

  .site-header .site-nav__list {
    gap: 0;
  }

  .site-header .site-nav__link {
    padding-inline: 6px;
    font-size: 0.875rem;
  }

  .lang-switch {
    margin-left: 2px;
  }

  .lang-switch__item {
    min-width: 28px;
    padding-inline: 6px;
  }
}

/* Desktop: a touch larger so the header does not look undersized on wide screens */
@media (min-width: 1024px) {
  .site-header .brand {
    font-size: 1.15625rem;
  }

  .site-header .brand__mark {
    width: 28px;
    height: 28px;
  }

  .site-header .site-nav__link {
    padding-inline: 14px;
    font-size: 1rem;
  }
}

/* Buttons ---------------------------------------------------------------- */

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 24px;
  border: 1px solid transparent;
  border-radius: var(--radius-button);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
  transition: transform var(--duration) var(--ease), background-color var(--duration) var(--ease),
    border-color var(--duration) var(--ease), color var(--duration) var(--ease);
}

.button--primary {
  background: var(--accent-strong);
  color: #fff;
}

.button--primary:hover {
  background: #8b5cf6;
  transform: translateY(-1px);
}

.button--secondary {
  border-color: var(--border-strong);
  color: var(--text);
  background: rgba(255, 255, 255, 0.02);
}

.button--secondary:hover {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-1px);
}

.button__arrow {
  width: 16px;
  height: 16px;
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  color: var(--accent-text);
  font-weight: 600;
  font-size: 0.9375rem;
  transition: color var(--duration) var(--ease), gap var(--duration) var(--ease);
}

.text-link:hover {
  color: var(--text);
  gap: 10px;
}

.text-link svg {
  width: 16px;
  height: 16px;
}

/* Hero ------------------------------------------------------------------- */

.hero {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  padding-block: clamp(4.5rem, 13vh, 9rem) clamp(4rem, 11vh, 7.5rem);
  border-bottom: 1px solid var(--border);
}

.hero::before,
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

/* faint grid */
.hero::before {
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 70% 20%, #000 20%, transparent 75%);
  mask-image: radial-gradient(ellipse 80% 70% at 70% 20%, #000 20%, transparent 75%);
}

/* soft violet glow, upper right */
.hero::after {
  background:
    radial-gradient(ellipse 50% 45% at 82% 12%, rgba(124, 58, 237, 0.16), transparent 70%),
    radial-gradient(ellipse 40% 40% at 60% 0%, rgba(99, 102, 241, 0.08), transparent 70%);
}

.hero--compact {
  padding-block: clamp(3.5rem, 10vh, 6.5rem) clamp(2.5rem, 7vh, 4.5rem);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  color: var(--accent-text);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1.5;
}

.eyebrow::before {
  content: "";
  width: 24px;
  height: 1px;
  background: currentColor;
  flex-shrink: 0;
}

.hero__title {
  font-size: clamp(2.5rem, 10.5vw, 7rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.045em;
}

.hero__tagline {
  margin-top: clamp(20px, 3vw, 32px);
  font-size: clamp(1.75rem, 5.2vw, 3.25rem);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.03em;
}

.hero__tagline span {
  display: block;
}

.hero__tagline span:nth-child(2) {
  color: var(--text-muted);
}

.hero__tagline span:nth-child(3) {
  color: var(--accent-text);
  background: linear-gradient(90deg, #c4b5fd, #8b5cf6 55%, #818cf8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero__lead {
  max-width: 34em;
  margin-top: clamp(24px, 3.5vw, 36px);
  color: var(--text-muted);
  font-size: clamp(1rem, 2.2vw, 1.125rem);
}

.hero .button-row {
  margin-top: clamp(28px, 4vw, 40px);
}

/* Home hero: Selected Work column (desktop only) */

.hero__selected {
  display: none;
}

@media (min-width: 1024px) {
  .hero--home {
    padding-block: clamp(4.5rem, 10vh, 7rem) clamp(4rem, 9vh, 6rem);
  }

  /* move the glow over the Selected Work column */
  .hero--home::after {
    background:
      radial-gradient(ellipse 42% 55% at 78% 35%, rgba(124, 58, 237, 0.13), transparent 70%),
      radial-gradient(ellipse 40% 40% at 60% 0%, rgba(99, 102, 241, 0.07), transparent 70%);
  }

  .hero__layout {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.75fr);
    gap: clamp(4rem, 7vw, 8rem);
    align-items: center;
  }

  .hero--home .hero__title {
    font-size: clamp(4rem, 6.4vw, 5.75rem);
  }

  .hero__selected {
    display: block;
  }
}

.selected-work__title {
  margin-bottom: 12px;
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1.5;
}

.selected-work__list {
  border-top: 1px solid var(--border);
}

.selected-work__item {
  border-bottom: 1px solid var(--border);
  transition: border-color var(--duration) var(--ease);
}

.selected-work__item:hover {
  border-bottom-color: var(--border-strong);
}

.selected-work__link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 16px;
  padding-block: 18px;
}

.selected-work__name {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.015em;
  transition: color var(--duration) var(--ease);
}

.selected-work__meta {
  grid-column: 1;
  margin-top: 2px;
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  line-height: 1.6;
}

.selected-work__icon {
  grid-column: 2;
  grid-row: 1 / span 2;
  width: 20px;
  height: 20px;
  color: var(--text-subtle);
  transition: color var(--duration) var(--ease), transform var(--duration) var(--ease);
}

.selected-work__link:hover .selected-work__name {
  color: var(--accent-text);
}

.selected-work__link:hover .selected-work__icon {
  color: var(--accent-text);
  transform: translate(2px, -2px);
}

.selected-work__stats {
  display: grid;
  gap: 4px;
  margin-top: 24px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.6;
}

.selected-work__count {
  margin-right: 6px;
  color: var(--text);
}

.page-title {
  font-size: clamp(2.5rem, 8vw, 5rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.page-lead {
  max-width: 36em;
  margin-top: 20px;
  color: var(--text-muted);
  font-size: clamp(1rem, 2.2vw, 1.125rem);
}

/* Sections --------------------------------------------------------------- */

.section {
  padding-block: clamp(4rem, 8vw, 6rem);
}

.section + .section {
  border-top: 1px solid var(--border);
}

.section-head {
  margin-bottom: clamp(32px, 5vw, 56px);
}

.section-title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.section-lead {
  margin-top: 12px;
  color: var(--text-muted);
}

.group + .group {
  margin-top: clamp(48px, 7vw, 72px);
}

.group-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 20px;
}

.group-title {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.group-count {
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.group-head::after {
  content: "";
  flex: 1;
  height: 1px;
  align-self: center;
  background: var(--border);
}

.section-foot {
  margin-top: 40px;
}

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

.project-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 640px) {
  .project-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
  }
}

@media (min-width: 1024px) {
  .project-grid--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.project-grid > li {
  display: flex;
}

.project-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 220px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 60%), var(--bg-card);
  transition: transform var(--duration) var(--ease), border-color var(--duration) var(--ease),
    background-color var(--duration) var(--ease);
}

.project-card--large {
  min-height: 260px;
  padding: clamp(24px, 3vw, 32px);
}

.project-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.project-category {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  line-height: 1.6;
}

/* per-project accent: a small dot before the category */
.project-category::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--project-accent);
  flex-shrink: 0;
}

.project-card__icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--text-subtle);
  transition: color var(--duration) var(--ease), transform var(--duration) var(--ease);
}

.project-title {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.project-card--large .project-title {
  font-size: clamp(1.5rem, 3vw, 1.875rem);
}

.project-subtitle {
  margin-top: 2px;
  color: var(--text-subtle);
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
}

.project-description {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.7;
}

.project-card__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-top: auto;
  padding-top: 24px;
}

.project-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.4;
}

.project-status__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.project-status--released {
  color: var(--text);
}

.project-status--released .project-status__dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18);
}

.project-status--development {
  color: var(--text-muted);
}

.project-status--development .project-status__dot {
  border: 1.5px solid var(--accent-text);
}

.project-note {
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

/* Released: the whole card is a link (stretched link, no nesting) */
.project-link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: var(--radius-card);
}

.project-link:focus-visible {
  outline: none;
}

.project-link:focus-visible::after {
  outline: 2px solid var(--accent-text);
  outline-offset: 3px;
}

.project-card--released:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--project-accent) 40%, transparent);
  background-color: var(--bg-card-hover);
}

.project-card--released:hover .project-card__icon {
  color: var(--accent-text);
  transform: translate(2px, -2px);
}

/* Project accents (kept subtle; the card UI itself is shared) */
.project-card {
  --project-accent: var(--accent);
}

.project-card--devdroid {
  --project-accent: #818cf8;
}

.project-card--jutsuju {
  --project-accent: #a78bfa;
}

.project-card--anlesso {
  --project-accent: #67c3d6;
}

.project-card--endrok {
  --project-accent: #d4a55a;
}

.project-card--chibikuma {
  --project-accent: #8fcf9c;
}

/* In development: quieter surface */
.project-card--development {
  background: linear-gradient(180deg, rgba(139, 92, 246, 0.045), transparent 55%), var(--bg-elevated);
}

/* About ------------------------------------------------------------------ */

.about-grid {
  display: grid;
  gap: 32px;
}

@media (min-width: 900px) {
  .about-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
    gap: 64px;
  }
}

.prose p {
  color: var(--text-muted);
  font-size: clamp(1rem, 2vw, 1.0625rem);
  line-height: 1.95;
}

.prose p + p {
  margin-top: 1.25em;
}

.prose strong {
  color: var(--text);
  font-weight: 600;
}

.prose--large p {
  font-size: clamp(1.0625rem, 2.2vw, 1.25rem);
}

.stack {
  margin-top: 40px;
}

.stack__label {
  margin-bottom: 14px;
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.area-list {
  display: grid;
  gap: 12px;
}

@media (min-width: 640px) {
  .area-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .area-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.area {
  padding: 20px 22px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-card);
}

.area__title {
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.area__text {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.7;
}

/* 404 -------------------------------------------------------------------- */

.not-found {
  display: flex;
  align-items: center;
  min-height: calc(100vh - var(--header-height) - 200px);
}

.not-found__code {
  color: var(--accent-text);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  letter-spacing: 0.14em;
}

/* Footer ----------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  padding-block: 48px;
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px 48px;
}

.site-footer__brand {
  font-weight: 700;
  font-size: 1.0625rem;
}

.site-footer__tag {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.site-footer__copy {
  margin-top: 16px;
  color: var(--text-subtle);
  font-size: 0.8125rem;
}

.site-footer .site-nav__list {
  margin-inline: -12px;
}

/* Reveal on scroll (only applied by JS, so content is visible without JS) */

.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 600ms var(--ease), transform 600ms var(--ease);
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* Reduced motion --------------------------------------------------------- */

@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;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }

  .button:hover,
  .project-card--released:hover,
  .project-card--released:hover .project-card__icon,
  .selected-work__link:hover .selected-work__icon {
    transform: none;
  }
}
