/* public/kusuma/kusuma.css — Kusuma, a painter's gallery.
   Mobile first; wider layouts are added with min-width queries.
   Fonts: Cormorant Garamond (English), Noto Serif Telugu (తెలుగు). */

:root {
  --paper: #f5efe3;
  --paper-2: #ece3d2;
  --ink: #2a221d;
  --ink-soft: #6b5d52;
  --rule: #d9cdb8;
  --accent: #9a3b2b;          /* madder red */
  --accent-ink: #fff8ef;
  --mat: #fbf8f1;
  --mat-edge: #e6dccb;
  --wall-shadow: 0 18px 40px -18px rgba(40, 25, 10, .45), 0 4px 10px -4px rgba(40, 25, 10, .25);
  --frame-w: 14px;
  --mat-w: 22px;
  --en: 'Cormorant Garamond', 'Iowan Old Style', Georgia, serif;
  --te: 'Noto Serif Telugu', 'Kohinoor Telugu', serif;
  --ui: 'Cormorant Garamond', Georgia, serif;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --wood-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='60'%3E%3Cfilter id='w'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.01 .35' numOctaves='3'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .35 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23w)'/%3E%3C/svg%3E");
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #191512; --paper-2: #231d18; --ink: #efe5d6; --ink-soft: #b3a493;
    --rule: #3a3029; --accent: #d97a5f; --accent-ink: #1b1411;
    --mat: #2a231e; --mat-edge: #1d1814;
    --wall-shadow: 0 18px 40px -16px rgba(0, 0, 0, .8), 0 4px 10px -4px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #191512; --paper-2: #231d18; --ink: #efe5d6; --ink-soft: #b3a493;
  --rule: #3a3029; --accent: #d97a5f; --accent-ink: #1b1411;
  --mat: #2a231e; --mat-edge: #1d1814;
  --wall-shadow: 0 18px 40px -16px rgba(0, 0, 0, .8), 0 4px 10px -4px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
/* `hidden` means hidden. Without this, any class that sets display (.k-btn is
   inline-flex) quietly wins, and a hidden button shows anyway — "Show more"
   on an empty gallery was exactly that. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  background: var(--paper) var(--grain); color: var(--ink);
  font: 400 19px/1.55 var(--en);
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }

/* LONG TEXT. Nothing here may push the page sideways: a pasted link or a word
   with no spaces breaks wherever it must, and grid children may shrink below
   their content (a grid item's default min-width is its longest word). */
.k-mat, .k-caption, .k-tile-cap, .k-cal-list, .k-sheet, .k-item, .k-intro, .k-panel-head,
.k-field, .k-box, .k-who { overflow-wrap: anywhere; }
.k-piece > *, .k-columns > *, .k-col, .k-panel, .k-grid > *, .k-desk-grid > *, .k-ed-head > *, .k-write > * { min-width: 0; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
.k-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ── Masthead ─────────────────────────────────────────────────────────── */
.k-top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 16px 10px; max-width: 1180px; margin: 0 auto;
}
.k-mark { display: flex; align-items: baseline; gap: 10px; text-decoration: none; }
.k-mark-te { font: 500 26px/1 var(--te); color: var(--accent); }
.k-mark-en { font: 500 24px/1 var(--en); letter-spacing: .14em; text-transform: uppercase; }
.k-top-nav { display: flex; gap: 14px; align-items: baseline; flex: none; }
.k-top-nav a { white-space: nowrap; }
.k-foot { max-width: 1180px; margin: 0 auto; padding: 28px 16px calc(28px + env(safe-area-inset-bottom)); display: flex; gap: 16px; justify-content: center; font-size: 15px; color: var(--ink-soft); }
.k-foot a { color: inherit; text-decoration: none; border-bottom: 1px solid var(--rule); }
@media print { .k-foot, .k-top-nav { display: none !important; } }
.k-top-link { font-size: 16px; color: var(--ink-soft); text-decoration: none; border-bottom: 1px solid var(--rule); }
.k-intro { max-width: 1180px; margin: 4px auto 18px; padding: 0 16px; color: var(--ink-soft); font-style: italic; font-size: 20px; }

main { max-width: 1180px; margin: 0 auto; padding: 0 16px 64px; }

/* ── Frames ───────────────────────────────────────────────────────────────
   A frame is three layers: the moulding (.k-frame, its padding is the frame
   width), the mat (.k-mat, a bevelled window), and what sits on it. Pure CSS,
   so it is sharp at any size and needs no image files. */
.k-frame {
  position: relative; padding: var(--frame-w);
  box-shadow: var(--wall-shadow);
}
.k-frame::after {           /* the inner lip where moulding meets mat */
  content: ""; position: absolute; inset: calc(var(--frame-w) - 3px);
  pointer-events: none; border-radius: 1px;
}
.k-frame[data-frame="gilt"] {
  background:
    linear-gradient(90deg, rgba(255,255,255,.0) 0 46%, rgba(255,255,255,.22) 50%, rgba(255,255,255,0) 54% 100%),
    linear-gradient(135deg, #7a5a22 0%, #e2c578 16%, #a8843a 32%, #f4e3a1 48%, #9b7731 64%, #dcbc6c 80%, #7c5c25 100%);
  box-shadow: var(--wall-shadow),
    inset 0 0 0 1px #5e4417, inset 0 0 0 3px rgba(255, 238, 180, .55),
    inset 0 0 0 5px rgba(110, 80, 25, .65), inset 0 0 10px 4px rgba(70, 45, 10, .35);
}
.k-frame[data-frame="gilt"]::after { box-shadow: 0 0 0 1px #6e5220, 0 0 0 3px rgba(255, 236, 170, .6); }
.k-frame[data-frame="wood"] {
  background: var(--wood-grain), linear-gradient(160deg, #4a2c19, #6b4329 35%, #3d2414 60%, #5b3820);
  box-shadow: var(--wall-shadow),
    inset 0 0 0 1px #1f120a, inset 0 2px 0 2px rgba(255, 220, 180, .12), inset 0 0 12px 3px rgba(0, 0, 0, .45);
}
.k-frame[data-frame="wood"]::after { box-shadow: 0 0 0 1px #1c0f07, 0 0 0 2px rgba(214, 170, 120, .35); }
.k-frame[data-frame="black"] {
  --frame-w: 8px;
  background: linear-gradient(135deg, #0d0d0d, #2b2b2b 45%, #0f0f0f 55%, #222);
  box-shadow: var(--wall-shadow), inset 0 0 0 1px #000, inset 0 1px 0 1px rgba(255, 255, 255, .08);
}

.k-mat {
  position: relative; background: var(--mat); padding: var(--mat-w);
  box-shadow: inset 0 0 0 1px var(--mat-edge),
    inset 2px 2px 0 rgba(0, 0, 0, .06), inset -1px -1px 0 rgba(255, 255, 255, .5),
    inset 0 0 18px rgba(80, 50, 20, .06);
}
.k-mat > .k-window {        /* the bevelled cut around a painting */
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .08), 0 0 0 4px var(--mat), 0 0 0 5px var(--mat-edge);
}

/* ── Gallery grid ─────────────────────────────────────────────────────── */
.k-grid { display: grid; grid-template-columns: 1fr; gap: 34px; }
/* A wall tile reads like a hung picture with a museum label under it. */
.k-tile { position: relative; width: 100%; max-width: 460px; justify-self: center; }
.k-tile a.k-tile-link { display: block; text-decoration: none; }
.k-tile .k-frame { --frame-w: 9px; --mat-w: 16px; transition: transform .25s ease, box-shadow .25s ease; }
@media (hover: hover) {
  .k-tile a.k-tile-link:hover .k-frame { transform: translateY(-3px); }
}
/* height: auto, or the img's height attribute (its real pixels, set to stop
   layout shift) wins over aspect-ratio and the tile becomes a tall strip. */
.k-tile img { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; background: var(--paper-2); }
.k-tile-cap { margin: 16px auto 0; padding: 10px 6px 0; border-top: 1px solid var(--rule); max-width: 92%; text-align: center; }
.k-tile-title { font: 600 21px/1.25 var(--en); margin: 0; letter-spacing: .01em; }
.k-tile-date { display: block; margin: 4px 0 0; font-size: 13px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-soft); }
.k-tile-line { margin: 6px 0 0; color: var(--ink-soft); font-style: italic; font-size: 17px; }
.k-tile-line::before { content: "“"; } .k-tile-line::after { content: "…”"; }
.k-tile-line.k-te { font-style: normal; font-size: 15px; line-height: 1.8; }
.k-tile-share { display: flex; justify-content: center; margin: 8px 0 0; }
.k-tile-share .k-btn { min-height: 34px; padding: 5px 12px; font-size: 15px; color: var(--ink-soft); }
.k-empty { text-align: center; color: var(--ink-soft); font-style: italic; padding: 60px 16px; }
.k-more { display: block; margin: 36px auto 0; }

/* ── Dates ── */
.k-caption-time { display: block; margin-top: 2px; font-size: 15px; letter-spacing: .04em; }

/* ── Wall / Calendar switch ── */
.k-views { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; padding: 3px; background: var(--paper-2); margin: 0 0 22px; }
.k-views button { border: 0; background: transparent; padding: 6px 16px; border-radius: 999px; cursor: pointer; font-size: 16px; min-height: 36px; }
.k-views button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.k-views button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Calendar: a month of days, each painting on the day it was painted ── */
.k-cal-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; }
.k-cal-title { font: 600 24px/1.2 var(--en); margin: 0; min-width: 9.5em; text-align: center; }
.k-cal-jump { width: auto; flex: 1 1 200px; max-width: 280px; font-size: 16px; padding: 7px 10px; }
.k-cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.k-cal-wd { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); text-align: center; padding: 4px 0; }
.k-cal-day {
  position: relative; aspect-ratio: 1; border-radius: 8px; background: var(--paper-2);
  border: 1px solid transparent; padding: 0; overflow: hidden; font: inherit; color: inherit;
}
.k-cal-pad { background: transparent; }
.k-cal-today { border-color: var(--accent); }
.k-cal-num { position: absolute; top: 3px; left: 5px; font-size: 13px; line-height: 1; z-index: 1; color: var(--ink-soft); }
.k-cal-has { cursor: pointer; box-shadow: 0 0 0 2px #c9a24b inset; }
.k-cal-has img { width: 100%; height: 100%; object-fit: cover; }
.k-cal-has .k-cal-num { background: rgba(251, 248, 241, .9); color: #2a221d; border-radius: 4px; padding: 2px 4px; top: 2px; left: 2px; }
.k-cal-count { position: absolute; right: 3px; bottom: 3px; background: var(--accent); color: var(--accent-ink); font-size: 12px; border-radius: 999px; padding: 1px 6px; }
.k-cal-has:hover img { transform: scale(1.04); }
.k-cal-has img { transition: transform .2s; }
.k-cal-has:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.k-cal-list { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 10px; }
.k-cal-list a { display: flex; gap: 12px; align-items: center; text-decoration: none; padding: 6px; border-radius: 10px; border: 1px solid var(--rule); background: var(--mat); }
.k-cal-list img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; flex: none; }
.k-cal-list strong { display: block; font: 600 19px/1.25 var(--en); }
.k-cal-list time { font-size: 15px; color: var(--ink-soft); }
@media (min-width: 640px) {
  .k-cal-grid { gap: 8px; }
  .k-cal-num { font-size: 15px; }
  .k-cal-list { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1000px) { .k-cal-list { grid-template-columns: repeat(3, 1fr); } }

/* ── A painting's page ────────────────────────────────────────────────── */
.k-piece { display: grid; gap: 28px; }
.k-figure { margin: 0; }
.k-figure .k-frame { --frame-w: 16px; --mat-w: 20px; }
.k-figure img { width: 100%; height: auto; }
.k-caption { margin: 14px 2px 0; color: var(--ink-soft); font-size: 17px; }
.k-caption-title { color: var(--ink); font: 600 26px/1.2 var(--en); margin: 0 0 4px; }
.k-caption-meta { letter-spacing: .04em; }
.k-caption-note { margin: 10px 0 0; font-style: italic; }

.k-langs[hidden] { display: none; }
.k-langs { justify-self: start; display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; padding: 3px; background: var(--paper-2); }
.k-langs button {
  border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; cursor: pointer;
  font-size: 16px; min-height: 36px;
}
.k-langs button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.k-langs [data-lang="te"] { font-family: var(--te); font-size: 15px; }
.k-langs [data-lang="both"] { display: none; }

.k-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.k-btn {
  display: inline-flex; align-items: center; gap: 7px; min-height: 40px;
  padding: 8px 14px; border: 1px solid var(--rule); border-radius: 999px;
  background: var(--paper); cursor: pointer; font-size: 16px; text-decoration: none;
}
.k-btn:hover { border-color: var(--ink-soft); }
.k-btn:focus-visible, .k-langs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.k-btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.k-btn-quiet { border-color: transparent; background: transparent; }
.k-btn svg { width: 16px; height: 16px; flex: none; }
.k-btn[disabled] { opacity: .5; cursor: default; }
.k-icon-btn { padding: 8px; min-width: 40px; justify-content: center; background: rgba(251, 248, 241, .92); }

.k-columns { display: grid; gap: 30px; }
.k-col[hidden] { display: none; }
.k-panel .k-frame { --frame-w: 12px; --mat-w: 22px; }
.k-panel-head { display: flex; justify-content: space-between; align-items: center; margin: 0 0 12px; gap: 8px; }
.k-panel-label { font-size: 14px; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-soft); }
.k-col[data-lang="te"] .k-panel-label { letter-spacing: .04em; text-transform: none; font-family: var(--te); }

/* The interpretation: a lede in italic, then a measure of ~65 characters. */
.k-lede { font-style: italic; font-size: 23px; line-height: 1.45; margin: 0 0 14px; }
.k-para { margin: 0 0 12px; max-width: 65ch; }
.k-para.k-first::first-letter {
  float: left; font-size: 3.3em; line-height: .82; padding: 6px 8px 0 0; color: var(--accent); font-weight: 600;
}

/* The poem: set like a printed page. */
.k-ornament { display: block; width: 120px; height: 20px; margin: 4px auto; color: var(--accent); opacity: .8; }
.k-poem-title {
  font: 600 22px/1.3 var(--en); font-variant: small-caps; letter-spacing: .08em;
  text-align: center; margin: 0 0 18px;
}
.k-poem { width: fit-content; max-width: min(34em, 100%); margin: 0 auto; }
.k-stanza { margin: 0 0 1.25em; font-size: 20px; line-height: 1.6; }
.k-stanza:last-child { margin-bottom: 0; }
.k-line { display: inline-block; padding-left: 1.4em; text-indent: -1.4em; }   /* hanging indent on a wrap */

/* Telugu wants more air: the vowel signs sit above and below the line. */
.k-te, .k-col[data-lang="te"] { font-family: var(--te); }
.k-col[data-lang="te"] .k-lede { font-style: normal; font-size: 20px; line-height: 1.9; }
.k-col[data-lang="te"] .k-para { font-size: 17.5px; line-height: 1.95; }
.k-col[data-lang="te"] .k-para.k-first::first-letter { float: none; font-size: inherit; padding: 0; color: inherit; font-weight: inherit; }
.k-col[data-lang="te"] .k-poem-title { font: 600 20px/1.6 var(--te); font-variant: normal; letter-spacing: 0; }
.k-col[data-lang="te"] .k-stanza { font-size: 18.5px; line-height: 1.95; }

.k-missing { color: var(--ink-soft); font-style: italic; margin: 0; }

/* Her signature, at the foot of every framed piece. */
.k-sign {
  margin: 22px 0 0; text-align: right; color: var(--accent);
  font: italic 500 21px/1.3 var(--en); letter-spacing: .02em;
}
.k-sign[lang="te"], .k-sign:lang(te) { font: 500 18px/1.7 var(--te); }

/* ── Small UI: toast, menus, dialogs ──────────────────────────────────── */
.k-toast {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 999px;
  font-size: 16px; opacity: 0; transition: opacity .2s, transform .2s; z-index: 60; pointer-events: none;
  max-width: calc(100vw - 32px);
}
.k-toast.k-show { opacity: 1; transform: translate(-50%, 0); }

.k-sheet-back {
  position: fixed; inset: 0; background: rgba(20, 12, 6, .45); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center; padding: 16px;
}
.k-sheet {
  width: 100%; max-width: 440px; background: var(--paper) var(--grain); color: var(--ink);
  border-radius: 16px; padding: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
  max-height: calc(100vh - 32px); overflow: auto;
}
.k-sheet h2 { font: 600 24px/1.2 var(--en); margin: 0 0 8px; }
.k-sheet p { margin: 0 0 14px; color: var(--ink-soft); }
.k-sheet-row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.k-sheet-list { display: grid; gap: 6px; }
.k-sheet-list .k-btn { justify-content: flex-start; border-radius: 10px; width: 100%; }
@media (min-width: 640px) { .k-sheet-back { align-items: center; } }

/* ── Forms (studio) ───────────────────────────────────────────────────── */
.k-field { display: grid; gap: 4px; margin: 0 0 12px; }
.k-field > span { font-size: 14px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); }
.k-input, .k-textarea, .k-select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 10px;
  background: var(--mat); font-size: 17px;
}
.k-textarea { min-height: 150px; resize: vertical; line-height: 1.6; }
.k-textarea.k-te { line-height: 1.9; }
.k-input:focus, .k-textarea:focus, .k-select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ── Wider screens ────────────────────────────────────────────────────── */
@media (min-width: 640px) {
  :root { --frame-w: 18px; --mat-w: 30px; }
  .k-grid { grid-template-columns: repeat(2, 1fr); gap: 44px 36px; }
  .k-top { padding: 26px 24px 12px; }
  main, .k-intro { padding-left: 24px; padding-right: 24px; }
  .k-panel .k-frame { --frame-w: 16px; --mat-w: 38px; }
  .k-figure .k-frame { --frame-w: 22px; --mat-w: 34px; }
}
@media (min-width: 1000px) {
  .k-grid { grid-template-columns: repeat(3, 1fr); }
  .k-langs [data-lang="both"] { display: inline-block; }
  .k-columns.k-both { grid-template-columns: 1fr 1fr; align-items: start; }
  .k-figure { max-width: 860px; margin: 0 auto; }
}

/* ── Print: one painting and its words on a clean page ────────────────── */
@media print {
  body { background: #fff; color: #000; font-size: 12pt; }
  .k-top-link, .k-actions, .k-langs, .k-panel-head button, .k-tile-share, .k-toast { display: none !important; }
  .k-col[hidden] { display: block !important; }
  .k-frame { box-shadow: none !important; break-inside: avoid; }
  .k-panel { break-inside: avoid; }
  main { padding: 0; }
}

@media (prefers-reduced-motion: reduce) { .k-toast { transition: none; } }
