/* try.kurolight.dev — project switcher */

:root {
  --bg: #f3eee2;
  --card: #fffdf8;
  --ink: #25272a;
  --muted: #62605a;
  --line: rgba(37, 39, 42, 0.11);
  --shade: rgba(37, 39, 42, 0.05);
  --btn: #25272a;
  --btn-ink: #fbf8f1;
  --btn-hover: #3d5a78;
  --accent: #4d6f91;
  --backdrop: rgba(30, 28, 24, 0.5);
  --shadow: 0 1px 2px rgba(37, 39, 42, 0.06), 0 6px 18px -8px rgba(37, 39, 42, 0.18);
  --shadow-up: 0 2px 4px rgba(37, 39, 42, 0.06), 0 16px 32px -12px rgba(37, 39, 42, 0.3);

  --pad: clamp(16px, 3vw, 32px);
  --gap: 20px;
  --head: 64px;
  --row: clamp(225px, calc((100svh - var(--head) - 4 * var(--gap)) / 3.08), 330px);
  --radius: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151618;
    --card: #1f2023;
    --ink: #ece8df;
    --muted: #a5a29a;
    --line: rgba(236, 232, 223, 0.1);
    --shade: rgba(236, 232, 223, 0.05);
    --btn: #ece8df;
    --btn-ink: #1a1b1d;
    --btn-hover: #b9cde2;
    --accent: #9fbad6;
    --backdrop: rgba(0, 0, 0, 0.62);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px -8px rgba(0, 0, 0, 0.5);
    --shadow-up: 0 2px 4px rgba(0, 0, 0, 0.3), 0 18px 36px -12px rgba(0, 0, 0, 0.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151618;
  --card: #1f2023;
  --ink: #ece8df;
  --muted: #a5a29a;
  --line: rgba(236, 232, 223, 0.1);
  --shade: rgba(236, 232, 223, 0.05);
  --btn: #ece8df;
  --btn-ink: #1a1b1d;
  --btn-hover: #b9cde2;
  --accent: #9fbad6;
  --backdrop: rgba(0, 0, 0, 0.62);
  color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; }
html:has(dialog[open]) { overflow: hidden; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; }
button { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
code { font: 0.9em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--shade); padding: 0.1em 0.35em; border-radius: 5px; }

svg { width: 1em; height: 1em; flex: none; }
.sprite { display: none; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- header / footer ---------- */

.top, .foot, main {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding-inline: var(--pad);
}

.top {
  height: var(--head);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.top h1 { margin: 0; font-size: 1.4rem; font-weight: 650; letter-spacing: -0.01em; }
.top h1 a { text-decoration: none; }
.top h1 a:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }

.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 28px calc(28px + env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 0.9rem;
}
.brand { display: inline-flex; align-items: center; gap: 7px; text-decoration: none; color: var(--muted); letter-spacing: 0.01em; }
.brand svg { width: 22px; height: 22px; color: var(--accent); }
.brand:hover { color: var(--ink); }
.ver { background: none; border: 0; padding: 8px 2px; color: var(--muted); cursor: pointer; font-variant-numeric: tabular-nums; }
.ver:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

main { flex: 1; }

/* ---------- grid ---------- */

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
}

.card {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
@media (hover: hover) {
  .card:hover { transform: translateY(-2px); box-shadow: var(--shadow-up); }
}
.card:has(.more:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* covers are 16:10, the same shape as the pictures, so they show whole */
.cover {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: 0% 50%; /* on phones, where cards are taller than the picture, keep the icon and name on the left */
  background: var(--shade);
  border-bottom: 1px solid var(--line);
}

.body {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "title go" "desc go";
  align-items: center;
  align-content: center;
  column-gap: 14px;
  row-gap: 2px;
  padding: 14px 16px 16px;
  background: var(--card);
}

.body h2 {
  grid-area: title;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 1.06rem;
  font-weight: 650;
  line-height: 1.25;
  min-width: 0;
}
.icon { width: 26px; height: 26px; border-radius: 7px; flex: none; object-fit: contain; }

.more {
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  text-align: left;
  cursor: pointer;
  font-weight: inherit;
  line-height: inherit;
}
/* the whole card opens the details: stretch the title button over it */
.more::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.more:focus-visible { outline: none; }

.desc {
  grid-area: desc;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
  min-height: 2.8em; /* two lines, so cards in a row line up */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.go {
  grid-area: go;
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--btn);
  color: var(--btn-ink);
  font-weight: 600;
  font-size: 0.93rem;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, transform 0.15s ease;
}
.go svg { width: 17px; height: 17px; }
.go:hover { background: var(--btn-hover); }
.go:active { transform: scale(0.97); }

/* ---------- desktop: two wide cards per row, picture on the left, details on the right ---------- */

@media (min-width: 1100px) {
  /* --row is the picture's height: about three rows (six cards) fit on screen */
  .top, .foot, main { max-width: min(1600px, calc(var(--row) * 5.4 + var(--gap) + 2 * var(--pad))); }
  .card {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(230px, 1fr);
  }
  .cover {
    height: 100%;
    border-bottom: 0;
    border-right: 1px solid var(--line);
  }
  .body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 8px;
    padding: 20px 22px;
  }
  .body h2 { font-size: 1.2rem; gap: 11px; }
  .body .icon { width: 30px; height: 30px; border-radius: 8px; }
  .desc { min-height: 0; font-size: 0.95rem; line-height: 1.45; -webkit-line-clamp: 4; }
  .go { margin-top: 10px; }
}

/* ---------- phones: two columns, about four cards on screen ---------- */

@media (max-width: 760px) {
  :root {
    --gap: 12px;
    --head: 56px;
    --radius: 14px;
    --row: clamp(236px, calc((100svh - var(--head) - 3 * var(--gap)) / 2.15), 380px);
  }
  .top h1 { font-size: 1.15rem; }
  .grid { grid-auto-rows: var(--row); }
  .cover { flex: 1 1 auto; min-height: 0; height: 100%; aspect-ratio: auto; }
  .body {
    flex: none;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "title" "desc" "go";
    align-items: start;
    row-gap: 4px;
    padding: 10px 10px 10px;
  }
  .body h2 { font-size: 0.95rem; gap: 7px; }
  .icon { width: 22px; height: 22px; border-radius: 6px; }
  .desc { font-size: 0.8rem; line-height: 1.35; }
  .go { margin-top: 6px; min-height: 38px; width: 100%; font-size: 0.88rem; }
  .go svg { width: 16px; height: 16px; }
}

@media (max-width: 340px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- dialogs ---------- */

dialog {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  max-width: none;
  max-height: none;
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}
dialog::backdrop { background: var(--backdrop); }
dialog[open] { display: grid; place-items: center; padding: 24px; }

.sheet {
  position: relative;
  width: min(940px, 100%);
  max-height: min(900px, calc(100svh - 48px));
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  overscroll-behavior: contain;
}
.sheet.small { width: min(480px, 100%); }

dialog[open] .sheet { animation: rise 0.22s cubic-bezier(0.2, 0.9, 0.3, 1); }
dialog[open]::backdrop { animation: fade 0.2s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(0.985); } }
@keyframes fade { from { opacity: 0; } }

.close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: rgba(20, 20, 22, 0.55);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.close svg { width: 20px; height: 20px; }
.close:hover { background: rgba(20, 20, 22, 0.78); }
.sheet.small .close { background: var(--shade); color: var(--ink); }

.viewer {
  position: relative;
  flex: none;
  background: #0f1012;
}
.slides {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  aspect-ratio: 16 / 9;
  max-height: 52svh;
  width: 100%;
  outline: none;
}
.slides::-webkit-scrollbar { display: none; }
.slides img {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  scroll-snap-align: center;
  scroll-snap-stop: always;
}

.nav {
  position: absolute;
  top: 50%;
  translate: 0 -50%;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: rgba(20, 20, 22, 0.55);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.15s ease;
}
.nav svg { width: 22px; height: 22px; }
.nav:hover { background: rgba(20, 20, 22, 0.78); }
.nav:disabled { opacity: 0; pointer-events: none; }
.prev { left: 12px; }
.next { right: 12px; }
.viewer.single .nav, .viewer.single .dots { display: none; }

.dots {
  position: absolute;
  left: 50%;
  bottom: 10px;
  translate: -50% 0;
  display: flex;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 999px;
  background: rgba(20, 20, 22, 0.45);
}
.dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, 0.45); transition: background-color 0.15s ease, transform 0.15s ease; }
.dots i.on { background: #fff; transform: scale(1.15); }

.d-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 22px 28px 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.d-body h2 { display: flex; align-items: center; gap: 12px; margin: 0 0 10px; font-size: 1.5rem; font-weight: 650; letter-spacing: -0.01em; line-height: 1.2; }
.d-body h2 .icon { width: 36px; height: 36px; border-radius: 9px; }
.sheet.small .d-body h2 { padding-right: 44px; }
.d-content { max-width: 68ch; }
.d-content p, .d-content ul, .d-content ol, .d-body > ul { margin: 0 0 12px; color: var(--ink); line-height: 1.55; }
.d-content ul, .d-content ol, .d-body > ul { padding-left: 1.25em; }
.d-content li, .d-body > ul li { margin-bottom: 4px; }
.d-content .note { color: var(--muted); font-size: 0.93rem; }
.d-body h3 { margin: 6px 0 6px; font-size: 1rem; }
.d-body h3 span { color: var(--muted); font-weight: 400; margin-left: 6px; font-size: 0.9rem; }

.d-actions {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  padding: 14px 28px 22px;
}
.go.big { min-height: 48px; padding: 0 24px; font-size: 1rem; }
.go.big svg { width: 19px; height: 19px; }
.d-extra { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.d-extra a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.93rem;
}
.d-extra a svg { width: 17px; height: 17px; }
.d-extra a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

.back {
  margin-left: auto;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  font-weight: 500;
}
.back:hover { background: var(--shade); }
#detail .back { display: none; }

/* phones: details open as a bottom sheet, actions in thumb reach */
@media (max-width: 760px) {
  dialog[open] { place-items: end stretch; padding: 0; }
  .sheet {
    width: 100%;
    max-height: calc(100svh - 28px);
    border-radius: 20px 20px 0 0;
    border-bottom: 0;
  }
  .sheet.small { width: 100%; }
  dialog[open] .sheet { animation: slide 0.26s cubic-bezier(0.2, 0.9, 0.3, 1); }
  @keyframes slide { from { transform: translateY(40%); opacity: 0.4; } }
  .slides { aspect-ratio: 16 / 10; max-height: 38svh; }
  .nav { display: none; }
  .d-body { padding: 18px 18px 4px; }
  .d-body h2 { font-size: 1.3rem; }
  .d-body h2 .icon { width: 32px; height: 32px; }
  .d-actions {
    padding: 12px 18px calc(14px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "extra extra" "go back";
    gap: 6px 10px;
  }
  .sheet.small .d-actions { display: flex; justify-content: flex-end; }
  .d-extra { grid-area: extra; }
  .d-extra:empty { display: none; }
  .go.big { grid-area: go; width: 100%; padding: 0 16px; }
  #detail .back { grid-area: back; display: inline-flex; align-items: center; margin: 0; min-height: 48px; }
}

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