@font-face {
  font-family: "Messina Sans";
  src: url("/fonts/MessinaSans-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --text-primary: #111111;
  --border: #eef0f1;
  --text-secondary: #6c7684;
  --text-muted: #b0b7bf;
  --text-inactive: #86909c;
  --surface-muted: #f4f5f6;
  --bg: #ffffff;
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text-secondary);
  font-family: "Messina Sans", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", "Meiryo", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* -2% tracking, relative to each element's own font size */
body,
body * {
  letter-spacing: -0.02em;
}

/* Text selection block (mouse devices only; touchscreens keep the OS selection) */
@media (hover: hover) and (pointer: fine) {
  ::selection {
    background: #e8eaed;
  }
}

p {
  margin: 0;
}

.page {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
}

/* Left column */
.left {
  flex: 1 1 0;
  min-width: 0;
}

.left__content {
  padding: 80px 80px 0;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.logo {
  display: block;
  width: 94px;
  height: 20px;
}

.logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.menu {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--text-inactive);
}

/* Dotted underline links. The dots are a background (1px dot, 1px gap) so the
   spacing rounds to fit the word and the row always ends on a whole dot. */
.link {
  color: inherit;
  text-decoration: none;
  background-image: linear-gradient(to right, currentColor 50%, transparent 50%);
  background-position: 0 100%;
  background-size: 2px 1px;
  background-repeat: round no-repeat;
  -webkit-box-decoration-break: clone; /* a link that wraps rounds its dots per line */
  box-decoration-break: clone;
  transition: color 0.15s ease;
}

.link:hover,
.link.is-active {
  color: var(--text-primary);
}

/* Current page / chosen language: solid underline */
.link.is-active {
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 100% 1px;
  background-repeat: no-repeat;
}

/* Main column */
.main {
  flex: 0 1 560px;
  min-width: 0;
  max-width: 560px;
  padding: 80px 0;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.intro {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.strong {
  color: var(--text-primary);
}

.showcase {
  margin: 0;
  width: 100%;
  height: 380px;
  background: var(--surface-muted);
  overflow: hidden;
}

.showcase video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Live demo: on the page it is just a preview (the box opens the zoom);
   once zoomed it can be used */
.showcase iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  pointer-events: none;
  transition: opacity 300ms ease; /* fades back in after a restart (zoom.js) */
}

.zoom-media iframe {
  pointer-events: auto;
}

/* Desktop: a short hint 16px under a zoomed demo (zoom.js places it) */
.zoom-caption {
  position: fixed;
  z-index: 101;
  left: 0;
  right: 0;
  margin: 0;
  padding: 0 40px;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  color: var(--text-muted);
  pointer-events: none;
}

/* Mobile: one line pinned 24px above the bottom of the screen (demo note or photo caption) */
.zoom-caption--mobile {
  top: auto;
  bottom: 24px;
  padding: 0 20px;
  font-size: 11px;
}

/* Mobile: a zoomed demo is only shown larger, not used */
.zoom-media.is-preview iframe {
  pointer-events: none;
}

/* Index: "Something i built recently" — each video with a caption under it */
.built {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 8px; /* 40px main gap + 8px = 48px */
}

.built__list {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.built__item {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.built__caption {
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  color: var(--text-inactive);
}

/* "New" next to a fresh project's name: once the project is on screen the word fades in
   and a pen scribble (right, left, right) draws itself under it (new-badge.js adds
   .is-shown, then .is-drawn). */
/* The name stays centred on its own; the badge hangs off its right edge */
.has-badge {
  position: relative;
  display: inline-block;
}
.new-badge {
  position: absolute;
  left: 100%;
  top: 0;
  margin-left: 0.45em;
  white-space: nowrap;
  color: #e0218a;
  opacity: 0;
  filter: blur(10px);
  /* same blur + fade as the page's blocks when they first appear (intro.js) */
  transition: opacity 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94), filter 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.new-badge.is-shown { opacity: 1; filter: none; }
.new-badge svg {
  position: absolute;
  left: 50%;
  top: 1.28em; /* just under the baseline */
  width: 2.5em;
  height: 0.5em;
  transform: translateX(-50%);
  overflow: visible;
  pointer-events: none;
}
.new-badge path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}
.new-badge.is-drawn path {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 700ms cubic-bezier(0.45, 0.05, 0.25, 1);
}

.page-title {
  margin: 0;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
}

/* About */
.experiences {
  --company-col: 180px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.experiences__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.experience {
  position: relative;
  display: grid;
  grid-template-columns: var(--company-col) 1fr auto;
  align-items: start;
}

.experience + .experience {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* Second role at the same company: divider starts at the role column */
.experience + .experience--continued {
  border-top-color: transparent;
}

.experience + .experience--continued::before {
  content: "";
  position: absolute;
  top: -1px;
  left: var(--company-col);
  right: 0;
  height: 1px;
  background: var(--border);
}

.experience__company {
  justify-self: start;
}

.experience__role {
  color: var(--text-primary);
}

.experience__year {
  text-align: right;
  white-space: nowrap;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 0;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 14px;
  border-radius: 40px;
  font-size: 13px;
  line-height: 1.4;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.button--primary {
  background: var(--text-primary);
  color: #ffffff;
}

.button--primary:hover {
  opacity: 0.88;
}

.button--secondary {
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.button--secondary:hover {
  background: #f9fafa;
}

/* Works: two-column grid */
.works {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.work__image {
  display: block;
  width: 100%;
  height: auto;
  background: var(--surface-muted);
}

/* Moments */
.moments {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.moments__col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.moments__image {
  display: block;
  width: 100%;
  height: auto;
  background: var(--surface-muted);
}

/* Projects */
.project {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.project__title {
  align-self: flex-start;
}

.project__case {
  align-self: center;
  font-size: 14px;
  color: var(--text-inactive);
}

.project__case--locked {
  color: var(--text-muted);
}

.project__image {
  display: block;
  width: 100%;
  height: auto;
}

/* Keeps the video's own 4:3 shape at any width (no letterboxing or cropping) */
.project__video {
  aspect-ratio: 1920 / 1440;
  object-fit: cover;
  background: var(--surface-muted);
}

.right {
  flex: 1 1 0;
  min-width: 0;
}

/* Language switch: EN / 日 */
.lang-switch {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  line-height: 1.5;
  white-space: nowrap;
}

.lang-switch__option {
  margin: 0;
  padding: 0;
  border: 0;
  background-color: transparent;
  font: inherit;
  color: var(--text-inactive);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.lang-switch__option.is-active {
  color: var(--text-primary);
}

/* Desktop shows the switch top-right; the in-menu copy is for mobile */
.lang-switch--menu {
  display: none;
}

/* Desktop: sidebar is fixed so it stays put while the page rubber-bands */
@media (min-width: 1001px) {
  .left__content {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1;
  }

  .lang-switch--desktop {
    position: fixed;
    top: 80px;
    right: 80px;
    z-index: 1;
  }

  /* Sidebar and language switch (Figma: Index desktop) */
  .left__content {
    padding-top: 78px;
  }

  .menu {
    gap: 6px;
  }

  /* Index */
  .main--index {
    font-size: 14px;
  }

  .main--index .group {
    gap: 6px;
  }

  .built__item {
    gap: 10px;
  }

  .built__caption {
    font-size: 13px;
  }

  /* Projects, Works and Frames */
  .main--projects,
  .main--works,
  .main--moments {
    font-size: 14px;
  }

  .main--projects .group,
  .main--works .group,
  .main--moments .group {
    gap: 6px;
  }

  .project + .project {
    margin-top: -8px; /* 40px main gap - 8px = 32px */
  }

  .project__case {
    margin-top: -6px; /* 16px project gap - 6px = 10px under the video */
    font-size: 13px;
  }

  /* About */
  .main--about {
    gap: 32px;
    font-size: 14px;
  }

  .main--about .group {
    gap: 6px;
  }

  .main--about .experiences {
    --company-col: 160px;
    gap: 10px;
  }

  .main--about .experience + .experience {
    margin-top: 10px;
    padding-top: 10px;
  }

  .experience__year {
    color: var(--text-inactive);
  }
}

/* Mobile header parts (hidden on desktop) */
.menu-toggle,
.left__divider {
  display: none;
}

/* Mobile & tablet (Figma: 375px frames) */
@media (max-width: 1000px) {
  .page {
    flex-direction: column;
    align-items: stretch;
  }

  .right {
    display: none;
  }

  /* Header sticks to the top; it slides up while scrolling down and back on scroll up */
  .left {
    position: sticky;
    top: 0;
    z-index: 50;
    transition: transform 480ms cubic-bezier(0.32, 0.72, 0, 1);
    will-change: transform;
  }

  .left.is-hidden {
    transform: translateY(-100%);
  }

  /* Header: logo + menu toggle, collapsible menu, divider */
  .left__content {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 0;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 24px 20px 0;
    background: var(--bg);
  }

  .logo {
    width: 113px;
    height: 24px;
  }

  .menu-toggle {
    display: block;
    position: relative;
    width: 24px;
    height: 24px;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .menu-toggle__line {
    position: absolute;
    left: 4px;
    width: 16px;
    height: 1.5px;
    background: #000000;
    transition: transform 420ms cubic-bezier(0.32, 0.72, 0, 1);
  }

  .menu-toggle__line:first-child {
    top: 8px;
  }

  .menu-toggle__line:last-child {
    top: 16px;
  }

  /* Open: both lines meet in the middle (Figma "Active") */
  .left__content.is-open .menu-toggle__line:first-child {
    transform: translateY(3.25px);
  }

  .left__content.is-open .menu-toggle__line:last-child {
    transform: translateY(-4.75px);
  }

  .menu-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 520ms cubic-bezier(0.32, 0.72, 0, 1);
  }

  .left__content.is-open .menu-panel {
    grid-template-rows: 1fr;
  }

  .menu {
    min-height: 0;
    overflow: hidden;
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    grid-template-rows: repeat(3, auto);
    grid-auto-flow: column;
    justify-items: start;
    column-gap: 12px;
    row-gap: 6px;
    padding-top: 0;
    transition: padding-top 520ms cubic-bezier(0.32, 0.72, 0, 1);
  }

  .left__content.is-open .menu {
    padding-top: 20px;
  }

  .menu .lang-switch--menu {
    display: flex;
    gap: 10px;
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
  }

  .left__divider {
    display: block;
    grid-column: 1 / -1;
    height: 1px;
    margin-top: 24px;
    background: var(--border);
  }

  /* Main */
  .main {
    flex: 1 0 auto;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 23px 20px 24px; /* 23px + 1px header divider = 24px, as in Figma */
    gap: 24px;
    font-size: 14px;
  }

  .group {
    gap: 6px;
  }

  /* Index */
  .main--index .intro {
    gap: 16px;
  }

  .built {
    gap: 12px;
    margin-top: 16px; /* 24px main gap + 16px = 40px */
  }

  .built__list {
    gap: 20px;
  }

  .built__item {
    gap: 10px;
  }

  .built__caption {
    font-size: 12px;
  }

  .showcase {
    height: auto;
    aspect-ratio: 560 / 380;
  }

  /* Projects */
  .project {
    gap: 12px;
  }

  .project__case {
    margin-top: -2px; /* 12px project gap - 2px = 10px under the video */
    font-size: 12px;
  }

  /* Works and Frames: one column; Frames follows its reading order (moments.js sets
     each photo's `order`, the columns dissolve so the photos interleave) */
  .works {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }

  .moments {
    flex-direction: column;
    align-items: stretch;
    gap: 24px;
  }

  .moments__col {
    display: contents;
  }

  /* About */
  .main--about .intro {
    gap: 16px;
  }

  .main--about .experiences {
    --company-col: 120px;
    gap: 10px;
  }

  .main--about .experience + .experience {
    margin-top: 10px;
    padding-top: 10px;
  }
}

@media (max-width: 1000px) {
  .page {
    min-height: 100vh;
    min-height: 100dvh;
  }
}

/* Page transitions: fade only the main column, keep the sidebar still */
@view-transition {
  navigation: auto;
}

.main {
  view-transition-name: main;
}

.left__content {
  view-transition-name: sidebar;
}

.lang-switch--desktop {
  view-transition-name: lang;
}

::view-transition-group(root),
::view-transition-group(lang),
::view-transition-old(lang),
::view-transition-new(lang),
::view-transition-group(sidebar),
::view-transition-old(sidebar),
::view-transition-new(sidebar) {
  animation: none;
}

::view-transition-old(root) {
  display: none;
}

::view-transition-group(main) {
  animation: none;
}

::view-transition-old(main) {
  animation: fade-out 140ms cubic-bezier(0.4, 0, 1, 1) both;
}

/* The new page's main blocks animate themselves (intro.js), so no container fade */
::view-transition-new(main) {
  animation: none;
}

@keyframes fade-out {
  to {
    opacity: 0;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}


@media (prefers-reduced-motion: reduce) {
  .new-badge { opacity: 1; filter: none; }
  .new-badge path { stroke-dashoffset: 0; }

  ::view-transition-old(main),
  ::view-transition-new(main) {
    animation: none;
  }

  .main {
    animation: none;
  }
}

/* Zoom (click media to view larger) */
.showcase,
.work__image,
.moments__image {
  cursor: pointer;
}

.showcase:focus-visible,
.work__image:focus-visible,
.moments__image:focus-visible {
  outline: 2px solid var(--text-primary);
  outline-offset: 4px;
}

/* No page scrollbar while zoomed (the page still scrolls to the shown media behind) */
html.is-zoomed {
  scrollbar-width: none;
}

html.is-zoomed::-webkit-scrollbar {
  display: none;
}

.zoom-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  cursor: zoom-out;
}

.zoom-media {
  position: fixed;
  z-index: 101;
  margin: 0;
  max-width: none;
  aspect-ratio: auto;
  object-fit: cover;
  transform-origin: 0 0;
  will-change: transform;
  cursor: default;
}

/* Left half steps back, right half steps forward, with the OS's own resize arrows */
.zoom-media.is-prev {
  cursor: w-resize;
}

.zoom-media.is-next {
  cursor: e-resize;
}

/* Intro: centered logo placeholder until intro.js takes over */
html.is-intro:not(.is-intro-ready) .main,
html.is-intro:not(.is-intro-ready) .menu,
html.is-intro:not(.is-intro-ready) .lang-switch--desktop,
html.is-intro:not(.is-intro-ready) .menu-toggle,
html.is-intro:not(.is-intro-ready) .left__divider,
html.is-enter:not(.is-enter-ready) .main {
  opacity: 0;
}

html.is-intro .logo {
  visibility: hidden;
}

html.is-intro.is-intro-ready .logo {
  visibility: visible;
  position: relative;
  z-index: 2;
  will-change: transform;
}

html.is-intro:not(.is-intro-ready) body::after {
  content: "";
  position: fixed;
  left: 50%;
  top: 50%;
  width: 94px;
  height: 20px;
  margin: -10px 0 0 -47px;
  background: url("/assets/logo.png") center / contain no-repeat;
  z-index: 200;
}

@media (max-width: 1000px) {
  html.is-intro:not(.is-intro-ready) body::after {
    width: 113px;
    height: 24px;
    margin: -12px 0 0 -56.5px;
  }
}

/* Language: hide text until the saved language is applied, then a simple fade on switch */
html.lang-pending [data-i18n] {
  visibility: hidden;
}

[data-i18n] {
  transition: opacity 200ms ease, color 0.15s ease;
}

/* While the intro / page-enter animation runs it hides and reveals these itself;
   a transition here would make them fade out visibly instead of hiding instantly. */
html.is-intro [data-i18n],
html.is-enter [data-i18n] {
  transition: none;
}

html.is-lang-fading [data-i18n] {
  opacity: 0 !important;
  transition: opacity 200ms ease !important;
}

@media (prefers-reduced-motion: reduce) {
  [data-i18n] {
    transition: none;
  }
}
