@layer base, layout, components, utilities;

:root {
  color-scheme: dark;

  /* Color tokens */
  --bg: #07060a;
  --bg-2: #0d0a12;
  --card: rgba(15, 11, 19, 0.84);
  --card-2: rgba(10, 8, 13, 0.96);
  --card-hover: rgba(24, 16, 32, 0.92);
  --line: #2e1a2a;
  --line-strong: rgba(255, 46, 132, 0.52);
  --text: #f5f0f6;
  --text-dim: #b8aebc;
  --pink: #ff2e84;
  --pink-soft: #ff6ca8;
  --violet: #9b5cff;

  /* Typography */
  --font-sans: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  --font-serif: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", Georgia, serif;

  /* Radii & layout */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;
  --wrap-max: 960px;
  --header-h: 57px;
}

@layer base {

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

  html {
    scroll-behavior: smooth;
    scrollbar-color: var(--line-strong) var(--bg);
    scrollbar-width: thin;
  }

  body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.8;
    overflow-wrap: break-word;
    -webkit-font-smoothing: antialiased;
  }

  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background:
      radial-gradient(ellipse 55% 38% at 80% 5%, rgba(91, 29, 120, 0.2), transparent 70%),
      radial-gradient(ellipse 50% 42% at 10% 35%, rgba(255, 46, 132, 0.07), transparent 70%);
  }

  a {
    color: var(--pink-soft);
    text-underline-offset: 0.2em;
  }

  img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
  }

  figure {
    margin: 0;
  }

  button {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
  }

  p {
    margin: 0 0 0.875rem;
    text-wrap: pretty;
  }

  h1,
  h2,
  h3 {
    text-wrap: balance;
  }

  strong {
    color: var(--pink-soft);
  }

  :where(a, button, [tabindex]):focus-visible {
    outline: 2px solid var(--pink);
    outline-offset: 3px;
    border-radius: 4px;
  }
}

@layer layout {
  #abyss {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
  }

  .grid-layer {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background-image:
      linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
    background-size: 38px 38px;
    -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 90%);
    mask-image: linear-gradient(180deg, #000 0%, transparent 90%);
  }

  .noise-layer {
    position: fixed;
    inset: 0;
    z-index: 50;
    pointer-events: none;
    opacity: 0.1;
    mix-blend-mode: soft-light;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
  }

  .scanline-layer {
    position: fixed;
    inset: 0;
    z-index: 51;
    pointer-events: none;
    opacity: 0.055;
    background-image: repeating-linear-gradient(180deg,
        rgba(255, 255, 255, 0.22) 0,
        rgba(255, 255, 255, 0.22) 1px,
        transparent 1px,
        transparent 4px);
  }

  .site-head,
  .wrap {
    position: relative;
    z-index: 2;
  }

  .wrap {
    max-width: var(--wrap-max);
    margin-inline: auto;
    padding-inline: 1.25rem;
    background: rgba(7, 6, 10, 0.9);
  }

  @media (min-width: 768px) {
    .wrap {
      padding-inline: 2.25rem;
      border-inline: 1px solid rgba(46, 26, 42, 0.55);
      box-shadow: 0 0 80px rgba(0, 0, 0, 0.65);
    }
  }

  .skip-link {
    position: fixed;
    inset-inline-start: 0.75rem;
    inset-block-start: -4rem;
    padding: 0.5rem 1rem;
    background: var(--card-2);
    color: var(--text);
    border: 1px solid var(--pink);
    border-radius: 8px;
    text-decoration: none;
    z-index: 80;
    transition: inset-block-start 0.15s ease;
  }

  .skip-link:focus {
    inset-block-start: 0.75rem;
  }

  /* Site Header */
  .site-head {
    position: sticky;
    top: 0;
    z-index: 30;
    border-bottom: 1px solid var(--line);
    background: rgba(7, 6, 10, 0.82);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
  }

  .site-head-inner {
    max-width: var(--wrap-max);
    margin-inline: auto;
    padding: 0.5rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
  }

  .site-head .brand {
    font-family: var(--font-serif);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    min-block-size: 40px;
    white-space: nowrap;
  }

  .top-nav {
    display: none;
    align-items: center;
    gap: 0.2rem;
  }

  .top-nav a {
    display: inline-flex;
    align-items: center;
    min-block-size: 36px;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-pill);
    font-size: 0.8125rem;
    color: var(--text-dim);
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.18s ease, background-color 0.18s ease;
  }

  .top-nav a:hover {
    color: var(--text);
    background: rgba(255, 46, 132, 0.12);
  }

  @media (min-width: 768px) {
    .top-nav {
      display: flex;
    }
  }

  /* Chapters & Sections */
  .chapter-group {
    margin-block-start: 3.5rem;
    padding-block-start: 1.5rem;
    border-top: 1px solid var(--line);
  }

  .chapter-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--pink-soft);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    margin: 0 0 0.5rem;
  }

  .flow-block {
    padding-block: 1.75rem 1.25rem;
    scroll-margin-top: calc(var(--header-h) + 16px);
    content-visibility: auto;
    contain-intrinsic-size: auto 480px;
  }

  .flow-block+.flow-block {
    margin-block-start: 1.25rem;
  }

  .flow-block h2 {
    font-family: var(--font-serif);
    font-size: clamp(1.375rem, 1.15rem + 0.8vw, 1.75rem);
    font-weight: 700;
    line-height: 1.35;
    margin: 0 0 1.25rem;
    letter-spacing: 0.04em;
  }

  .flow-block h3 {
    font-family: var(--font-serif);
    font-size: 1.0625rem;
    font-weight: 700;
    line-height: 1.45;
    letter-spacing: 0.08em;
    margin: 0 0 1rem;
    color: var(--text);
  }
}

@layer components {

  /* Hero */
  .hero {
    padding-block: 2.75rem 1rem;
    scroll-margin-top: var(--header-h);
  }

  .hero-kicker {
    font-size: 0.8125rem;
    color: var(--pink-soft);
    letter-spacing: 0.14em;
    margin: 0 0 0.5rem;
  }

  .hero h1 {
    font-family: var(--font-serif);
    font-size: clamp(2.5rem, 1.75rem + 2.8vw, 3.5rem);
    line-height: 1.18;
    margin: 0 0 0.875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
  }

  .hero-statement {
    font-size: clamp(1.0625rem, 1rem + 0.4vw, 1.2rem);
    margin: 0 0 1.25rem;
    max-width: 34ch;
  }

  .hero-about {
    max-width: 54ch;
  }

  .prof-line {
    font-size: 0.95rem;
    margin: 0 0 0.75rem;
  }

  .lead {
    font-size: 1.0625rem;
  }

  .dim {
    color: var(--text-dim);
    font-size: 0.9375rem;
  }

  figure.hero-img {
    position: relative;
    width: min(100%, 360px);
    margin: 1.75rem auto 0;
    padding: 14px;
    background:
      repeating-linear-gradient(90deg,
        rgba(255, 255, 255, 0.02) 0,
        rgba(255, 255, 255, 0.02) 1px,
        transparent 1px,
        transparent 28px),
      radial-gradient(ellipse 62% 46% at 58% 34%, rgba(255, 46, 132, 0.25), transparent 70%),
      linear-gradient(145deg, rgba(31, 15, 43, 0.62), rgba(6, 6, 8, 0.82));
    box-shadow: inset 0 0 60px rgba(255, 46, 132, 0.07), 0 24px 70px rgba(0, 0, 0, 0.45);
  }

  figure.hero-img::before {
    content: "";
    position: absolute;
    inset-inline: 0;
    bottom: 6px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 46, 132, 0.85) 50%, transparent);
    box-shadow: 0 0 18px rgba(255, 46, 132, 0.7);
    pointer-events: none;
  }

  figure.hero-img::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    border: 1px solid rgba(255, 46, 132, 0.52);
    clip-path: polygon(0 0, 26px 0, 26px 2px, 2px 2px, 2px 26px, 0 26px, 0 0,
        calc(100% - 26px) 0, 100% 0, 100% 26px, calc(100% - 2px) 26px, calc(100% - 2px) 2px, calc(100% - 26px) 2px, calc(100% - 26px) 0,
        0 0, 0 calc(100% - 26px), 0 100%, 26px 100%, 26px calc(100% - 2px), 2px calc(100% - 2px), 2px calc(100% - 26px), 0 calc(100% - 26px),
        0 0, 100% 0, 100% calc(100% - 26px), 100% 100%, calc(100% - 26px) 100%, calc(100% - 26px) calc(100% - 2px), calc(100% - 2px) calc(100% - 2px), calc(100% - 2px) calc(100% - 26px), 100% calc(100% - 26px), 100% 0, 0 0);
  }

  figure.hero-img img {
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--radius-sm);
    width: 100%;
  }

  .hero-overlay {
    margin-block-start: 0.75rem;
    background: rgba(10, 8, 13, 0.88);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 0.625rem 0.875rem;
  }

  .hero-overlay .overlay-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 0.125rem;
    line-height: 1.45;
  }

  .hero-overlay .overlay-desc {
    font-size: 0.8125rem;
    color: var(--text-dim);
    margin: 0;
    line-height: 1.55;
  }

  @media (min-width: 900px) {
    .hero {
      display: grid;
      grid-template-columns: 1fr minmax(0, 380px);
      gap: 2.75rem;
      align-items: center;
      padding-block: 3.25rem 1.5rem;
    }

    figure.hero-img {
      width: 100%;
      max-width: 380px;
      margin: 0;
    }
  }

  /* Buttons & CTAs */
  .cta-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-block-size: 44px;
    padding: 0.6rem 1.4rem;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--card);
    color: var(--pink-soft);
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.15s ease;
  }

  .cta-button:hover {
    background: var(--card-hover);
    border-color: var(--pink);
    transform: translateY(-1px);
  }

  .cta-primary {
    border-color: var(--pink);
    background: rgba(255, 46, 132, 0.1);
    color: var(--text);
  }

  .cta-primary:hover {
    background: rgba(255, 46, 132, 0.2);
  }

  /* Performance (Centered Minimal Embed + 2 Links) */
  .perf-center {
    display: grid;
    justify-items: center;
    gap: 1.125rem;
  }

  .perf-center .embed-card {
    width: min(100%, 400px);
  }

  .perf-links {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
  }

  .perf-links a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-block-size: 40px;
    padding: 0.4rem 1.1rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    text-decoration: none;
    font-size: 0.875rem;
    color: var(--pink-soft);
    transition: border-color 0.18s ease, background-color 0.18s ease, transform 0.15s ease;
  }

  .perf-links a:hover {
    border-color: var(--line-strong);
    background: var(--card-hover);
    transform: translateY(-1px);
  }

  /* Embeds */
  .embed-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 0.875rem;
  }

  .embed-card--minimal {
    padding: 0.5rem;
  }

  .embed-frame {
    position: relative;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--bg-2);
    overflow: hidden;
  }

  .embed-frame.suno {
    height: 240px;
  }

  .embed-frame.insta {
    aspect-ratio: 9 / 16;
    min-height: 540px;
    max-height: 660px;
    width: 100%;
  }

  .embed-fallback {
    display: block;
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-dim);
    text-decoration: none;
    padding: 0.45rem 0 0.15rem;
  }

  .embed-fallback:hover {
    color: var(--pink-soft);
    text-decoration: underline;
  }

  .embed-frame iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
  }

  .embed-load {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 0.35rem;
    padding: 1.25rem 1rem;
    background:
      radial-gradient(circle at 50% 40%, rgba(255, 46, 132, 0.1), transparent 68%),
      var(--bg-2);
    color: var(--text);
    border: 0;
    cursor: pointer;
    font-size: 0.9375rem;
    line-height: 1.5;
    transition: background-color 0.2s ease;
  }

  .embed-load:hover {
    background:
      radial-gradient(circle at 50% 40%, rgba(255, 46, 132, 0.2), transparent 68%),
      #140d1d;
  }

  .embed-load .play {
    display: inline-grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--line-strong);
    background: rgba(255, 46, 132, 0.12);
    font-size: 1.25rem;
    color: var(--pink-soft);
    padding-inline-start: 2px;
    margin-block-end: 0.2rem;
    transition: transform 0.18s ease, background-color 0.18s ease;
  }

  .embed-load:hover .play {
    transform: scale(1.06);
    background: rgba(255, 46, 132, 0.24);
  }

  .embed-load small {
    font-size: 0.78rem;
    color: var(--text-dim);
    line-height: 1.6;
  }

  /* Gear */
  .gear-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  @media (min-width: 700px) {
    .gear-grid {
      grid-template-columns: repeat(2, 1fr);
    }
  }

  .gear-grid img {
    width: 100%;
    border: 1px solid var(--line);
  }

  /* Photo Masonry Gallery (handles mixed sizes & aspect ratios naturally) */
  .photo-group {
    margin-block-end: 3rem;
  }

  .photo-group:last-child {
    margin-block-end: 0;
  }

  .photo-masonry {
    list-style: none;
    margin: 0;
    padding: 0;
    columns: 1;
    column-gap: 0.875rem;
  }

  @media (min-width: 560px) {
    .photo-masonry {
      columns: 2;
    }
  }

  @media (min-width: 900px) {
    .photo-masonry:has(> :nth-child(7)) {
      columns: 3;
    }
  }

  .photo-masonry li {
    break-inside: avoid;
    margin-block-end: 0.875rem;
  }

  .photo-masonry figure {
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-2);
    border: 1px solid rgba(255, 255, 255, 0.06);
  }

  .photo-masonry img {
    width: 100%;
    border-radius: 0;
    transition: filter 0.25s ease;
  }

  .photo-masonry figure:hover img {
    filter: brightness(1.04);
  }

  /* Songs */
  .featured-track {
    margin-block-end: 1.125rem;
    border-color: var(--line-strong);
  }

  .track-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.625rem;
  }

  @media (min-width: 768px) {
    .track-list {
      grid-template-columns: repeat(2, 1fr);
    }
  }

  .track-list li {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color 0.18s ease, background-color 0.18s ease;
  }

  .track-list li:hover {
    border-color: var(--line-strong);
    background: var(--card-hover);
  }

  .track-list a {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 0.625rem;
    min-block-size: 54px;
    padding: 0.7rem 0.95rem;
    text-decoration: none;
    color: var(--text);
  }

  .track-title {
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.4;
  }

  .track-meta {
    font-size: 0.75rem;
    color: var(--text-dim);
    white-space: nowrap;
  }

  .track-list .arrow {
    color: var(--pink-soft);
    font-size: 0.95rem;
  }

  .songs-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-block-start: 1.25rem;
  }

  .tags {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .tags li {
    font-size: 0.8125rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-pill);
    padding: 0.2rem 0.75rem;
    color: var(--text-dim);
  }

  /* Links (時雨Pの生息地) */
  .end-block {
    margin-block-start: 3.5rem;
    padding-block: 2rem 0.5rem;
    border-top: 1px solid var(--line);
    scroll-margin-top: calc(var(--header-h) + 16px);
  }

  .end-head {
    font-family: var(--font-serif);
    font-size: clamp(1.375rem, 1.15rem + 0.8vw, 1.65rem);
    line-height: 1.3;
    color: var(--text);
    font-weight: 700;
    border-inline-start: 3px solid var(--pink);
    padding-inline-start: 0.75rem;
    margin: 0 0 1.25rem;
  }

  .links-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.625rem;
  }

  .links-list li {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color 0.18s ease, background-color 0.18s ease;
  }

  .links-list li:hover {
    border-color: var(--line-strong);
    background: var(--card-hover);
  }

  .links-list a {
    display: grid;
    grid-template-columns: 136px 1fr auto;
    gap: 0.75rem 1rem;
    align-items: center;
    padding: 0.9rem 1rem;
    text-decoration: none;
    color: var(--text);
  }

  .links-list .plat {
    font-size: 1.0625rem;
    font-weight: 700;
  }

  .links-list .desc {
    font-size: 0.875rem;
    color: var(--text-dim);
  }

  .links-list .arrow {
    color: var(--pink-soft);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-pill);
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  @media (max-width: 600px) {
    .links-list a {
      grid-template-columns: 1fr auto;
    }

    .links-list .desc {
      grid-column: 1 / 3;
    }
  }

  .dm-row {
    margin-block-start: 1.25rem;
  }

  /* Footer */
  footer {
    border-top: 1px solid var(--line);
    padding: 1.75rem 0 5.5rem;
    font-size: 0.875rem;
    margin-block-start: 3rem;
  }

  footer .foot-in {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
  }

  footer p {
    margin: 0;
    color: var(--text-dim);
  }

  footer a {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    min-block-size: 36px;
    color: var(--pink-soft);
    text-decoration: none;
  }

  footer a:hover {
    text-decoration: underline;
  }

  /* Floating Jump Nav */
  .jump-nav {
    position: fixed;
    left: 50%;
    bottom: calc(0.75rem + env(safe-area-inset-bottom));
    transform: translate(-50%, 10px);
    z-index: 40;
    max-width: calc(100% - 1rem);
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    align-items: center;
    gap: 0.15rem;
    padding: 0.3rem 0.5rem;
    background: rgba(10, 8, 13, 0.92);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
  }

  .jump-nav::-webkit-scrollbar {
    display: none;
  }

  .jump-nav.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translate(-50%, 0);
  }

  .jump-nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-block-size: 34px;
    padding: 0.2rem 0.65rem;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    line-height: 1.4;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
    transition: color 0.15s ease, background-color 0.15s ease;
  }

  .jump-nav a:hover {
    color: var(--text);
    background: rgba(255, 46, 132, 0.14);
  }

  .jump-nav a.top-link {
    color: var(--pink-soft);
  }

  .jump-nav a[aria-current="location"] {
    color: var(--text);
    background: rgba(255, 46, 132, 0.26);
    border: 1px solid var(--line-strong);
  }
}

@layer utilities {
  @media (pointer: coarse) {
    .jump-nav a {
      min-block-size: 40px;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    html {
      scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }
}