/* ============================================================
   Musi-K - CUBE CSS (Composition, Utility, Block, Exception)
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  --ink: #1c1917;
  --muted: #78716c;
  --faint: #a8a29e;
  --line: #e7e5e4;
  --paper: #f4f2ec;
  --accent: #c2410c;
  --accent-alt: #be185d;

  --font-display: "Bodoni Moda", serif;
  --font-body: "Jost", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --space-3xs: 0.25rem;
  --space-2xs: 0.5rem;
  --space-xs: 0.75rem;
  --space-s: 1rem;
  --space-m: 1.5rem;
  --space-l: 2.5rem;
  --space-xl: 4rem;
  --space-2xl: 6rem;
  --space-3xl: 9rem;
  --space-4xl: 12rem;

  --radius: 4px;
  --stack-gap: var(--space-m);
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: #fbcfa0;
  color: #7c2d12;
}

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #d6d3d1;
  border-radius: 4px;
}

/* ---------- View transitions (cross-document) ----------
   Opts same-origin navigations (feed <-> single-note page, back/forward)
   into the View Transitions API. Unsupported browsers ignore this
   silently and just navigate normally, so it's pure enhancement. */

@view-transition {
  navigation: auto;
}

/* Whole-page crossfade for the parts of the page that aren't shared
   elements (header, surrounding cards, etc). */
::view-transition-old(root) {
  animation: 360ms cubic-bezier(0.4, 0, 1, 1) both vt-old-out;
}

::view-transition-new(root) {
  animation: 420ms cubic-bezier(0.16, 1, 0.3, 1) both vt-new-in;
}

@keyframes vt-old-out {
  to {
    opacity: 0;
    transform: scale(0.985);
  }
}

@keyframes vt-new-in {
  from {
    opacity: 0;
    transform: scale(1.015);
  }
}

/* Shared elements — a note's thumbnail and title (tagged with
   view-transition-name in note-card.php) morph position/size smoothly
   between the feed card and the single-note page. */
::view-transition-group(*) {
  animation-duration: 480ms;
  animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
}

::view-transition-image-pair(*) {
  isolation: isolate;
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation-duration: 1ms !important;
  }
}

/* ---------- Composition ----------
   Layout-only primitives. No color, no font-size. */

.wrapper {
  max-width: 72rem;
  margin-inline: auto;
  padding-inline: var(--space-m);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--stack-gap, var(--space-m));
}

.stack > * + * {
  /* margin-block-start: var(--stack-gap, var(--space-m)); */
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: var(--cluster-justify, flex-start);
  gap: var(--cluster-gap, var(--space-s));
}

.region {
  padding-block: var(--region-space, var(--space-xl));
}

/* ---------- Utilities ----------
   Single-purpose, low-specificity helpers. */

.u-eyebrow {
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

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

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

/* ---------- Blocks ---------- */

/* Site header */
.site-header {
  --region-space: var(--space-m);
  --cluster-justify: space-between;
  border-bottom: 1px solid var(--line);
}

.site-header__nav {
  --cluster-gap: var(--space-m);
}

.site-header__brand {
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  color: var(--ink);
}

.site-header__count {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.site-header__back,
.site-header__sort {
  font-size: 0.75rem;
  color: var(--muted);
  text-decoration: none;
}

.site-header__back:hover,
.site-header__sort:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* Hero */
.hero {
  position: relative;
  z-index: 10;
  max-width: 42rem;
  margin-block-end: 8rem;
}

.hero__stack {
  --stack-gap: var(--space-s);
}

.hero__decor {
  display: none;
  position: absolute;
  z-index: -1;
  top: -4rem;
  left: -3rem;
  width: 16rem;
  height: 20rem;
  background: rgb(214 211 209 / 50%);
  border-radius: var(--radius);
}

.hero__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2.25rem, 4vw + 1rem, 4.5rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.hero__title em {
  font-style: italic;
  color: var(--accent);
}

.hero__lede {
  margin: 0;
  max-width: 32rem;
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--muted);
}

@media (min-width: 48em) {
  .hero {
    margin-block-end: var(--space-4xl);
  }

  .hero__decor {
    display: block;
  }
}

/* Empty state */
.empty-state {
  color: var(--muted);
  font-size: 0.95rem;
}

/* Centered content */
html, body {
  height: calc(100% - 72px);
}

.centered-content {
  height: 100%;
  display: grid;
  place-items: center;
}

/* Region modifier for single-item pages (v.php, edit.php), which pair
   .centered-content with one card/form instead of a scrollable feed. */
.region--solo {
  --region-space: var(--space-xl) 0;

  &:has(.edit-form),
  &:has(.note-feed) {
    inline-size: 100%;
  }
}

/* Note feed */
.note-feed-region {
  --region-space: 0 var(--space-2xl);
}

.note-feed {
  list-style: none;
  inline-size: 100%;
  max-inline-size: 52rem;
  margin: 0 auto;
  padding: 0;
  --stack-gap: 8rem;
}

@media (min-width: 48em) {
  .note-feed {
    --stack-gap: var(--space-4xl);
  }
}

.note-card {
  --card-accent: var(--accent);
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-l);
  align-items: center;
}

.note-card__media-wrap {
  position: relative;
}

.note-card__media {
  display: block;
  width: 100%;
  max-width: 100%;
  margin-inline: auto;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 20px 40px -20px rgb(28 25 23 / 25%);
  outline: 1px solid rgb(28 25 23 / 6%);
  outline-offset: -1px;
  filter: grayscale(1);
  transition: filter 700ms ease;
}

.note-card:hover .note-card__media {
  filter: grayscale(0);
}

.note-card__body {
  --stack-gap: var(--space-xs);
}

/* Decorative accents — visual only, ui.html's Bauhaus/geometric motifs */
.note-card__decor {
  display: none;
  position: absolute;
  z-index: -1;
  pointer-events: none;
  border-radius: var(--radius);
}

.note-card__decor--circle {
  top: -1.5rem;
  left: -1.5rem;
  width: 8rem;
  height: 8rem;
  border-radius: 50%;
  background: #facc15;
  opacity: 0.6;
  mix-blend-mode: multiply;
  transition: transform 700ms ease;
}

.note-card:hover .note-card__decor--circle {
  transform: scale(1.1);
}

.note-card__decor--outline {
  inset: auto -2rem -2rem auto;
  width: 100%;
  height: 100%;
  border: 1px solid rgb(190 24 93 / 20%);
}

.note-card__decor--block {
  bottom: -1rem;
  right: -1rem;
  width: 12rem;
  height: 12rem;
  background: #d97d54;
  opacity: 0.2;
  mix-blend-mode: multiply;
}

.note-card__eyebrow {
  --cluster-gap: var(--space-s);
  color: var(--card-accent);
}

.note-card__eyebrow .rule {
  display: inline-block;
  width: 2.5rem;
  height: 1px;
  background: var(--card-accent);
}

.note-card__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.75rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.note-card__message {
  margin: 0;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--muted);
  white-space: pre-wrap;
}

.note-card__tags {
  --cluster-gap: var(--space-3xs) var(--space-2xs);
  margin: 0;
  padding: 0;
  list-style: none;
}

.note-card__tag {
  padding: 0.1rem 0 0.15rem;
  border-radius: 999px;
  font-size: 0.7rem;
  line-height: 1.5;
  letter-spacing: 0.06em;
  opacity: 0.75;
}

.note-card__tag a {
  color: var(--card-accent);
  text-decoration: none;
}

.note-card__tag a:hover {
  text-decoration: underline;
}

.note-card__meta {
  --cluster-gap: var(--space-s);
  font-size: 0.75rem;
  color: var(--faint);
}

.note-card__meta a {
  color: var(--card-accent);
  text-decoration: none;
}

.note-card__meta a:hover {
  text-decoration: underline;
}

.note-card__share {
  font: inherit;
  font-size: inherit;
  color: var(--card-accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.note-card__share:hover {
  text-decoration: underline;
}

.note-card__delete {
  display: inline-flex;
}

.note-card__delete button {
  font: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.note-card__delete button:hover {
  color: #b91c1c;
  text-decoration: underline;
}

.note-feed__status {
  margin-block-start: var(--space-l);
  min-height: 1.2em;
  text-align: center;
  font-size: 0.8rem;
}

/* Site footer */
.site-footer {
  --region-space: var(--space-m) 0;
  --cluster-justify: space-between;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Edit form (edit.php) */
.edit-form {
  --stack-gap: var(--space-m);
  inline-size: 100%;
  max-inline-size: 32rem;
  margin-inline: auto;
}

.edit-form__field {
  display: flex;
  flex-direction: column;
  gap: var(--space-3xs);
}

.edit-form__label {
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.edit-form__video {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.edit-form__video a {
  margin-inline-start: var(--space-2xs);
  color: var(--accent);
}

.edit-form__input,
.edit-form__textarea {
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
  font-size: 1rem;
  padding: var(--space-2xs) var(--space-xs);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  resize: vertical;
}

.edit-form__input:focus,
.edit-form__textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.edit-form__error {
  margin: 0;
  font-size: 0.85rem;
  color: #b91c1c;
}

.edit-form__actions {
  --cluster-gap: var(--space-m);
}

.button {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: var(--space-2xs) var(--space-m);
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff8f2;
  cursor: pointer;
}

.button:hover {
  filter: brightness(1.05);
}

/* ---------- Exceptions ----------
   One-off deviations from the base block, scoped tightly. */

@media (min-width: 64em) {
  .note-card__decor {
    display: block;
  }

  .note-card {
    grid-template-columns: 2fr 1fr;
    gap: var(--space-2xl);
  }

  .region--solo .note-card {
    grid-template-columns: 1fr;
  }

  .note-card--reverse {
    grid-template-columns: 1fr 2fr;
    --card-accent: var(--accent-alt);
  }

  .note-card--reverse .note-card__media-wrap {
    order: 2;
  }

  .note-card--reverse .note-card__body {
    order: 1;
  }
}

/* Editorial variant (3rd card in every rotation of 3) — a centered
   timeline layout instead of the media/body split used above. */
.note-card--editorial {
  align-items: start;
  max-width: 56rem;
  /* margin-inline: auto; */
  padding-block-start: var(--space-l);
}

.note-card--editorial .note-card__sidebar-date {
  color: var(--faint);
}

.note-card--editorial .note-card__content {
  --stack-gap: var(--space-s);
}

.note-card__timeline {
  display: none;
}

@media (min-width: 48em) {
  .note-card--editorial {
    grid-template-columns: 1fr 3fr;
    gap: var(--space-xl);
  }

  .note-card__timeline {
    display: block;
    position: absolute;
    top: 0;
    bottom: 0;
    left: -2.5rem;
    width: 1px;
    background: var(--line);
  }

  .note-card__timeline::before {
    content: "";
    position: absolute;
    top: 0.25rem;
    left: 50%;
    width: 0.75rem;
    height: 0.75rem;
    background: var(--ink);
    border-radius: 50%;
    box-shadow: 0 0 0 4px var(--paper);
    transform: translateX(-50%);
  }
}

@media (max-width: 30em) {
  .site-header {
    --cluster-justify: flex-start;
  }
}
