/* ---------- Themes ---------- */

:root {
  --bg: #f1f3fb;
  --surface: #ffffff;
  --text: #1c1530;
  --muted: #5b5577;
  --line: #1c1530;
  --shadow: #1c1530;
  --hairline: transparent;

  --soft: #c9d3fa;
  --soft-text: #1c1530;
  --soft-muted: #3a3358;
  --blue: #7d90e0;
  --red: #d42a2a;
  --on-red: #ffffff;
  --on-red-muted: #ffe3e3;

  --kaneo-bg: #1c1530;
  --kaneo-board: #2b2347;
  --kaneo-text: #ffffff;
  --kaneo-soft: #c9d3fa;
  --card-fill: #ffffff;

  --clock-bg: #7d90e0;
  --clock-stripe: #8c9ee8;
  --clock-text: #1c1530;

  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, monospace;

  --gap: 14px;
  --radius: 24px;
  --pad: 18px;

  color-scheme: light;
}

/* Riso print after dark: ink paper, lifted panels, the same red. */
:root[data-theme="night"] {
  --bg: #0f0b1c;
  --surface: #1c1630;
  --text: #eef0fa;
  --muted: #a7a1c4;
  --line: #eef0fa;
  --shadow: #7d90e0;

  --soft: #29305f;
  --soft-text: #eef0fa;
  --soft-muted: #b8c1f0;
  --blue: #6577cc;

  --kaneo-bg: #261e45;
  --kaneo-board: #342a5e;
  --card-fill: #eef0fa;

  --clock-bg: #3b4894;
  --clock-stripe: #4453a3;
  --clock-text: #eef0fa;

  color-scheme: dark;
}

/* Typing "kaneo" borrows Kaneo's own look for a few seconds: neutrals and Geist. */
:root[data-mode="kaneo"] {
  --bg: #fafafa;
  --surface: #ffffff;
  --text: #262626;
  --muted: #737373;
  --line: #262626;
  --shadow: #0a0a0a;
  --hairline: #e5e5e5;

  --soft: #f5f5f5;
  --soft-text: #262626;
  --soft-muted: #737373;
  --blue: #a1a1a1;
  --red: #0a0a0a;
  --on-red: #fafafa;
  --on-red-muted: #a1a1a1;

  --kaneo-bg: #0a0a0a;
  --kaneo-board: #262626;
  --kaneo-text: #fafafa;
  --kaneo-soft: #a1a1a1;
  --card-fill: #f5f5f5;

  --clock-bg: #f5f5f5;
  --clock-stripe: #ededed;
  --clock-text: #262626;

  --display: "Geist", system-ui, sans-serif;
}

:root[data-mode="kaneo"][data-theme="night"] {
  --bg: #141414;
  --surface: #1c1c1c;
  --text: #f5f5f5;
  --muted: #a1a1a1;
  --line: #f5f5f5;
  --shadow: #737373;
  --hairline: #2e2e2e;

  --soft: #262626;
  --soft-text: #f5f5f5;
  --soft-muted: #a1a1a1;
  --blue: #525252;
  --red: #f5f5f5;
  --on-red: #141414;
  --on-red-muted: #525252;

  --kaneo-bg: #262626;
  --kaneo-board: #333333;
  --card-fill: #e5e5e5;

  --clock-bg: #262626;
  --clock-stripe: #2e2e2e;
  --clock-text: #f5f5f5;
}

/* Theme switches use the View Transitions API: a circle wipe for night mode, a crossfade otherwise. */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.5s;
}

:root.vt-circle::view-transition-old(root),
:root.vt-circle::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

/* ---------- Base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  overflow-x: clip;
  background: var(--bg);
  color: var(--text);
  font-family: var(--display);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
p {
  margin: 0;
}

i {
  display: block;
}

button {
  font: inherit;
  color: inherit;
}

/* ---------- Layout ---------- */

.page {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 40px 20px 40px;
}

.bento {
  container-type: inline-size;
  min-width: 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: calc((100cqi - var(--gap)) / 2);
  gap: var(--gap);
}

/* ---------- Profile ---------- */

.profile {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 0 4px 26px;
}

.avatar-wrap {
  position: relative;
  align-self: flex-start;
  flex-shrink: 0;
}

.avatar {
  position: relative;
  display: block;
  width: 112px;
  height: 112px;
  padding: 0;
  overflow: hidden;
  border: 3px solid var(--line);
  border-radius: 24px;
  background: var(--soft);
  box-shadow: 5px 5px 0 var(--shadow);
  cursor: pointer;
  transform: rotate(-4deg);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  -webkit-tap-highlight-color: transparent;
}

.avatar:hover {
  transform: rotate(3deg) scale(1.03);
}

.avatar:focus-visible {
  outline: 3px solid var(--line);
  outline-offset: 4px;
}

.avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
}

/* Anime glasses glare, positioned on the lenses of pfp.png. */
.glare {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.glare__lens {
  position: absolute;
  border-radius: 28%;
  background: linear-gradient(115deg, #ffffff 0 40%, #e9eeff 40% 55%, #ffffff 55%);
  opacity: 0;
}

.glare__lens--left {
  left: 27.5%;
  top: 45.4%;
  width: 12.2%;
  height: 8%;
}

.glare__lens--right {
  left: 41.8%;
  top: 45%;
  width: 17%;
  height: 8%;
}

.avatar.is-glaring .glare__lens {
  animation: glare 1.6s ease-out;
}

@keyframes glare {
  0% {
    opacity: 0;
  }
  12%,
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.bubble {
  position: absolute;
  top: 2px;
  left: calc(100% + 22px);
  z-index: 2;
  padding: 8px 14px 9px;
  border: 2.5px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 3px 3px 0 var(--shadow);
  font-size: 18px;
  line-height: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  opacity: 0;
  transform: scale(0.6) rotate(-6deg);
  transform-origin: 0 100%;
  pointer-events: none;
  transition:
    opacity 0.15s ease,
    transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.bubble::before {
  content: "";
  position: absolute;
  bottom: 8px;
  left: -9px;
  width: 14px;
  height: 14px;
  border-bottom: 2.5px solid var(--line);
  border-left: 2.5px solid var(--line);
  border-bottom-left-radius: 3px;
  background: var(--surface);
  transform: rotate(45deg);
}

.bubble.is-visible {
  opacity: 1;
  transform: scale(1) rotate(-3deg);
}

/* Night mode switch, stuck on the avatar's corner like a sticker. */
.theme-toggle {
  position: absolute;
  right: -16px;
  bottom: -14px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 2.5px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 3px 3px 0 var(--shadow);
  color: var(--text);
  cursor: pointer;
  transform: rotate(8deg);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle:hover {
  transform: rotate(-10deg) scale(1.08);
}

.theme-toggle:active {
  transform: scale(0.92);
}

.theme-toggle:focus-visible {
  outline: 3px solid var(--line);
  outline-offset: 3px;
}

.theme-toggle svg {
  grid-area: 1 / 1;
  transition:
    transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.2s ease;
}

.theme-toggle__moon {
  color: var(--blue);
}

.theme-toggle__sun {
  color: #f2b705;
  opacity: 0;
  transform: rotate(-120deg) scale(0.3);
}

:root[data-theme="night"] .theme-toggle__moon {
  opacity: 0;
  transform: rotate(120deg) scale(0.3);
}

:root[data-theme="night"] .theme-toggle__sun {
  opacity: 1;
  transform: none;
}

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

.name {
  font-size: 88px;
  line-height: 80px;
  font-weight: 800;
  letter-spacing: -0.045em;
}

.bio {
  font-size: 18px;
  line-height: 26px;
  letter-spacing: -0.01em;
}

.location {
  display: flex;
  align-items: center;
  align-self: flex-start;
  gap: 6px;
  padding-top: 6px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 16px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.location__icon {
  display: grid;
  place-items: center;
  width: 18px;
  height: 20px;
  flex-shrink: 0;
}

.location__pin path {
  fill: #d42a2a;
  stroke: var(--line);
}

.location__pin circle {
  fill: #ffffff;
  stroke: var(--line);
}

/* ---------- Shared tile ---------- */

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  overflow: hidden;
  border-radius: var(--radius);
  outline: 1px solid var(--hairline);
  outline-offset: -1px;
  color: var(--text);
  text-decoration: none;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.tile:focus-visible {
  outline: 3px solid var(--line);
  outline-offset: 3px;
}

@media (hover: hover) {
  a.tile:hover,
  .tile--clock:hover {
    transform: translate(-3px, -3px);
    box-shadow: 6px 6px 0 var(--shadow);
  }
}

.label {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.label--muted {
  color: var(--muted);
}

/* ---------- Social tiles ---------- */

.tile--social {
  padding: var(--pad);
  background: var(--surface);
}

.tile__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.tile__top svg {
  flex-shrink: 0;
}

.tile__top .arrow {
  transition: transform 0.2s ease;
}

@media (hover: hover) {
  a.tile:hover .arrow {
    transform: translate(2px, -2px);
  }
}

.tile__text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.tile__title {
  font-size: 24px;
  line-height: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.handle {
  overflow: hidden;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 16px;
  color: var(--muted);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.handle--long {
  display: none;
}

.tile--bluesky {
  background: var(--soft);
  color: var(--soft-text);
}

.tile--bluesky .handle {
  color: var(--soft-muted);
}

.tile--kofi {
  background: var(--red);
  color: var(--on-red);
}

.tile--kofi .tile__title {
  font-size: 22px;
  line-height: 24px;
}

.tile--kofi .handle {
  color: var(--on-red-muted);
}

.cup {
  transform: rotate(-8deg);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (hover: hover) {
  .tile--kofi:hover .cup {
    transform: rotate(6deg);
  }
}

/* ---------- Kaneo ---------- */

.tile--kaneo {
  grid-column: span 2;
  grid-row: span 2;
  gap: 20px;
  padding: 24px 24px 0;
  background: var(--kaneo-bg);
  color: var(--kaneo-text);
}

.kaneo__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.kaneo__copy {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kaneo__copy .label {
  color: var(--kaneo-soft);
}

.kaneo__title {
  font-size: 56px;
  line-height: 54px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.kaneo__desc {
  max-width: 230px;
  font-size: 16px;
  line-height: 22px;
  color: var(--kaneo-soft);
}

.kaneo__arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #ffffff;
  color: var(--kaneo-bg);
  transition: transform 0.2s ease;
}

@media (hover: hover) {
  .tile--kaneo:hover .kaneo__arrow {
    transform: rotate(45deg);
  }
}

.board {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex: 0 1 118px;
  min-height: 0;
  overflow: hidden;
  padding: 14px 14px 0;
  border-radius: 18px 18px 0 0;
  background: var(--kaneo-board);
}

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

.board__bar {
  width: var(--w);
  height: 6px;
  flex-shrink: 0;
  border-radius: 3px;
  background: var(--c);
}

/* Kanban cards can be dragged between columns; dropping one in "done" throws confetti. */
.card {
  position: relative;
  height: var(--h);
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--card-fill);
  cursor: grab;
  touch-action: none;
}

.card.is-dragging {
  z-index: 2;
  cursor: grabbing;
  box-shadow: 0 10px 20px rgb(0 0 0 / 0.3);
}

.card--blue {
  background: var(--blue);
}

.card--tilt {
  transform: rotate(3deg);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (hover: hover) {
  .tile--kaneo:hover .card--tilt:not(.is-dragging) {
    transform: rotate(-4deg) translateY(-4px);
  }
}

.confetti {
  position: fixed;
  z-index: 100;
  width: 8px;
  height: 11px;
  border-radius: 2px;
  pointer-events: none;
}

/* ---------- Clock ---------- */

.tile--clock {
  grid-column: span 2;
  padding: 20px 22px;
  background: var(--clock-bg);
  color: var(--clock-text);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.stripes {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.stripes g {
  stroke: var(--clock-stripe);
}

.clock__top,
.clock__bottom {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.clock__top {
  align-items: center;
}

.clock__bottom {
  align-items: flex-end;
}

.clock__live {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}

.clock__time {
  font-size: 72px;
  line-height: 62px;
  font-weight: 800;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.clock__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  padding-bottom: 4px;
  text-align: right;
}

.clock__day {
  font-size: 17px;
  line-height: 22px;
  font-weight: 600;
}

.clock__zone {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 16px;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

/* ---------- Portfolio ---------- */

.tile--portfolio {
  grid-column: span 2;
  flex-direction: row;
  gap: 12px;
  padding: 20px 0 0 22px;
  background: var(--surface);
}

.portfolio__copy {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  padding-bottom: 20px;
}

.portfolio__text {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.portfolio__title {
  font-size: 28px;
  line-height: 30px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.portfolio__desc {
  font-size: 15px;
  line-height: 20px;
  color: var(--muted);
}

.window {
  display: flex;
  flex-direction: column;
  align-self: flex-end;
  width: 104px;
  height: 122px;
  flex-shrink: 0;
  overflow: hidden;
  border-top: 2px solid var(--line);
  border-left: 2px solid var(--line);
  border-top-left-radius: 14px;
  background: var(--bg);
  transition: transform 0.25s ease;
}

@media (hover: hover) {
  .tile--portfolio:hover .window {
    transform: translate(-6px, -6px);
  }
}

.window__bar {
  display: flex;
  gap: 5px;
  padding: 10px 12px;
  background: var(--soft);
}

.window__bar i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
}

.window__body {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 14px 12px;
}

.window__line {
  width: var(--w);
  height: var(--h, 6px);
  flex-shrink: 0;
  border-radius: 5px;
  background: var(--c, var(--soft));
}

.window__blocks {
  display: flex;
  gap: 6px;
  padding-top: 6px;
}

.window__blocks i {
  width: 48px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 6px;
  background: var(--c);
}

/* ---------- Typing "pride" ---------- */

.pride {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.pride[hidden] {
  display: none;
}

.pride__sticker {
  width: min(320px, 64vw);
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border: 4px solid var(--line);
  border-radius: 20px;
  box-shadow: 8px 8px 0 var(--shadow);
  transform: rotate(-6deg);
}

.pride__flag {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: 0 50%;
  animation: pride-wave 1.6s ease-in-out infinite;
}

@keyframes pride-wave {
  0%,
  100% {
    transform: skewY(0deg) scale(1.08);
  }
  50% {
    transform: skewY(-4deg) scale(1.08, 1.14);
  }
}

/* ---------- Konami code: everything falls ---------- */

:root.gravity .tile {
  pointer-events: none;
}

@media (max-width: 379px) {
  .clock__time {
    font-size: 60px;
    line-height: 54px;
  }
}

/* ---------- Tablet / small desktop: 4-column grid ---------- */

@media (min-width: 880px) {
  :root {
    --gap: 20px;
    --radius: 28px;
    --pad: 22px;
  }

  .page {
    max-width: 924px;
    gap: 48px;
    padding: 72px 40px;
  }

  .grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: calc((100cqi - 3 * var(--gap)) / 4);
  }

  .profile {
    flex-direction: row;
    align-items: center;
    gap: 48px;
    padding: 0 0 0 4px;
  }

  .avatar-wrap {
    align-self: center;
  }

  .avatar {
    width: 176px;
    height: 176px;
    border-radius: 32px;
    box-shadow: 6px 6px 0 var(--shadow);
  }

  .theme-toggle {
    right: -18px;
    bottom: -16px;
    width: 48px;
    height: 48px;
  }

  .intro {
    gap: 20px;
  }

  .name {
    font-size: 128px;
    line-height: 112px;
  }

  .bio {
    max-width: 340px;
    font-size: 22px;
    line-height: 31px;
  }

  .location {
    padding-top: 16px;
  }

  .label {
    font-size: 13px;
  }

  .tile--kaneo {
    padding: 28px 28px 0;
  }

  .kaneo__title {
    font-size: 64px;
    line-height: 60px;
  }

  .kaneo__desc {
    max-width: 250px;
    font-size: 17px;
    line-height: 24px;
  }

  .board {
    flex-basis: 150px;
  }

  .tile--clock {
    padding: 24px 28px;
  }

  .clock__time {
    font-size: 88px;
    line-height: 76px;
  }

  .clock__zone {
    font-size: 13px;
  }

  .tile--portfolio {
    padding: 24px 0 0 28px;
  }

  .portfolio__copy {
    padding-bottom: 24px;
  }

  .portfolio__title {
    font-size: 34px;
    line-height: 36px;
  }

  .portfolio__desc {
    font-size: 17px;
    line-height: 22px;
  }

  .window {
    width: 132px;
    height: 150px;
  }

  .tile--kofi .tile__title {
    font-size: 24px;
    line-height: 26px;
  }
}

/* ---------- Desktop: fills the window with an equal margin on every side ---------- */

@media (min-width: 880px) and (orientation: landscape) {
  :root {
    --edge: clamp(40px, 8vw, 144px);
  }

  html,
  body {
    height: 100%;
    overflow: hidden;
    /* No macOS trackpad rubber-band bounce either. */
    overscroll-behavior: none;
  }

  /*
   * Laid out at design size (at least 1232 × 628), then scaled to fill the window minus --edge.
   * script.js sets --page-w / --page-h / --fit; spare width goes between profile and grid,
   * spare height makes the tiles slightly taller.
   */
  .page {
    position: absolute;
    top: var(--edge);
    left: var(--edge);
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 48px;
    width: var(--page-w, 1232px);
    height: var(--page-h, 628px);
    max-width: none;
    margin: 0;
    padding: 0;
    transform: scale(var(--fit, 1));
    transform-origin: 0 0;
  }

  .profile {
    flex-direction: column;
    align-items: flex-start;
    gap: 36px;
    flex: 0 1 380px;
    min-width: 340px;
    padding: 0;
  }

  .avatar-wrap {
    align-self: flex-start;
  }

  .bento {
    align-self: stretch;
    width: 844px;
    flex-shrink: 0;
  }

  .grid {
    height: 100%;
    grid-template-rows: repeat(3, minmax(0, 1fr));
    grid-auto-rows: auto;
  }

  .handle--long {
    display: inline;
    font-size: 12px;
    letter-spacing: -0.02em;
  }

  .handle--short {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
