/* What each theme is made of: its colours live in style.css, its materials here. Every panel (cards, the game
   bar, the move panel, Settings, the chat) and every control (chips, tabs, inputs, dropdowns, buttons) reads the
   same handful of tokens, and each theme sets them:
     --m-tex / -size / -rep / -pos   a texture over panels (wood grain, lacquer waves, brushed steel, plate, driftwood)
     --m-r / --m-r-sm           corners of panels and of controls
     --m-edge                   the panels' border style and width (solid, a lacquer hairline, rope-like double)
     --m-rim                    an inner rim on panels (box-shadow)
     --m-ctl-tex / --m-ctl-rim  the controls' surface and bevel; --m-on is the glow of a pressed one
     --m-in-bg / --m-in-ink / --m-in-tex / --m-in-edge / --m-in-scheme   what you type on (parchment, washi, glass…)
     --m-head                   the font of headings
   West Texas by day is the default below; the night keeps its walnut, but by lamplight. */

:root {
  --m-tex: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='14'%3E%3Cpath d='M0 3q24-3 48 0t48 0M0 8q30 2 52 0t44 1M0 12q20-2 44 0t52-1' fill='none' stroke='%23000' stroke-opacity='.16'/%3E%3Cpath d='M0 5q30-2 56 0t40 0' fill='none' stroke='%23fff' stroke-opacity='.05'/%3E%3C/svg%3E");
  --m-tex-size: 96px 14px;
  --m-r: 14px; --m-r-sm: 10px;
  --m-edge: 2px solid;
  --m-rim: inset 0 1px 0 rgba(255, 230, 170, .12), inset 0 -2px 0 rgba(0, 0, 0, .25);
  --m-ctl-tex: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='5' height='5'%3E%3Cpath d='M0 0h1v1H0zM3 2h1v1H3zM1 4h1v1H1z' fill='%23000' fill-opacity='.18'/%3E%3Cpath d='M2 0h1v1H2zM4 3h1v1H4z' fill='%23fff' fill-opacity='.06'/%3E%3C/svg%3E");   /* tooled leather */
  --m-ctl-rim: inset 0 1px 0 rgba(255, 220, 150, .14), 0 2px 0 rgba(0, 0, 0, .3);
  --m-on: 0 0 0 1px var(--bag-light), 0 2px 0 var(--bag-shadow);
  --m-in-bg: #ecdcb4; --m-in-ink: #3a2410; --m-in-edge: #8a6a3c; --m-in-scheme: light;   /* parchment */
  --m-in-tex: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Ccircle cx='9' cy='12' r='7' fill='%238a5a20' fill-opacity='.05'/%3E%3Ccircle cx='30' cy='29' r='9' fill='%238a5a20' fill-opacity='.04'/%3E%3Cpath d='M3 33h1v1H3zM22 6h1v1h-1zM35 15h1v1h-1z' fill='%235a3a10' fill-opacity='.25'/%3E%3C/svg%3E");
  --m-head: var(--f-pixel);
}
:root[data-theme="night"] {   /* the same walnut and leather by lamplight; a dark slate to write on */
  --m-in-bg: #241a22; --m-in-ink: var(--ink); --m-in-edge: #5a4636; --m-in-scheme: dark;
  --m-in-tex: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='6'%3E%3Cpath d='M1 1h1v1H1zM4 4h1v1H4z' fill='%23fff' fill-opacity='.04'/%3E%3C/svg%3E");
  --m-rim: inset 0 1px 0 rgba(255, 200, 120, .1), inset 0 -2px 0 rgba(0, 0, 0, .3);
}
:root[data-theme="japan"] {   /* black lacquer with faint waves, a vermilion hairline inside a gold one, sharp corners; washi to write on */
  --m-tex: linear-gradient(180deg, rgba(255, 255, 255, .05), transparent 35%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='12'%3E%3Cg fill='none' stroke='%23c8a050' stroke-opacity='.07'%3E%3Cpath d='M0 12a12 12 0 0 1 24 0M4 12a8 8 0 0 1 16 0M8 12a4 4 0 0 1 8 0M-12 6a12 12 0 0 1 24 0M12 6a12 12 0 0 1 24 0'/%3E%3C/g%3E%3C/svg%3E");
  --m-tex-size: 100% 100%, 24px 12px;
  --m-r: 3px; --m-r-sm: 2px;
  --m-edge: 1px solid;
  --m-rim: inset 0 0 0 3px var(--panel-solid), inset 0 0 0 4px rgba(200, 160, 80, .45);
  --m-ctl-tex: linear-gradient(180deg, rgba(255, 255, 255, .07), transparent 55%);
  --m-ctl-rim: inset 0 0 0 1px rgba(200, 160, 80, .22);
  --m-on: inset 0 0 0 1px rgba(255, 220, 160, .55);
  --m-in-bg: #ebe3d0; --m-in-ink: #1a1424; --m-in-edge: #b8382a; --m-in-scheme: light;
  --m-in-tex: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Cg fill='none' stroke='%237a6a50' stroke-opacity='.13'%3E%3Cpath d='M2 9q8 3 15 1M20 30q9-4 16 0M30 6q5 6 12 5M5 40q6-3 12 1M38 38q4 4 9 2'/%3E%3C/g%3E%3C/svg%3E");   /* washi fibres */
  --m-head: "Shippori Mincho B1", "Noto Serif JP", Georgia, serif;
}
:root[data-theme="city"] {   /* brushed steel with a rivet in each corner, neon that glows when pressed; dark glass to write on */
  --m-tex: radial-gradient(circle at 9px 9px, #8a93a3 1.6px, #2a2d35 2.2px, transparent 2.6px),
    radial-gradient(circle at calc(100% - 9px) 9px, #8a93a3 1.6px, #2a2d35 2.2px, transparent 2.6px),
    radial-gradient(circle at 9px calc(100% - 9px), #8a93a3 1.6px, #2a2d35 2.2px, transparent 2.6px),
    radial-gradient(circle at calc(100% - 9px) calc(100% - 9px), #8a93a3 1.6px, #2a2d35 2.2px, transparent 2.6px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .028) 0 1px, transparent 1px 3px);
  --m-tex-size: auto;
  --m-r: 6px; --m-r-sm: 5px;
  --m-rim: inset 0 1px 0 rgba(255, 255, 255, .08), 0 0 0 1px rgba(63, 210, 232, .08);
  --m-ctl-tex: repeating-linear-gradient(0deg, rgba(255, 255, 255, .03) 0 1px, transparent 1px 3px);
  --m-ctl-rim: inset 0 1px 0 rgba(255, 255, 255, .07);
  --m-on: 0 0 10px color-mix(in srgb, var(--bag) 70%, transparent), inset 0 0 6px rgba(255, 255, 255, .25);
  --m-in-bg: #0a0c10; --m-in-ink: var(--ink); --m-in-edge: #3a5a66; --m-in-scheme: dark;
  --m-in-tex: linear-gradient(180deg, rgba(63, 210, 232, .07), transparent 60%);
}
:root[data-theme="harbor"] {   /* painted steel plate with a row of rivets, rope-like trim, corrugated container chips; weathered steel to write on */
  --m-tex: radial-gradient(circle, rgba(255, 255, 255, .2) 1.3px, rgba(0, 0, 0, .35) 1.8px, transparent 2.2px),
    radial-gradient(circle, rgba(255, 255, 255, .2) 1.3px, rgba(0, 0, 0, .35) 1.8px, transparent 2.2px),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10'%3E%3Cpath d='M1 2h1v1H1zM6 7h1v1H6zM8 1h1v1H8z' fill='%23fff' fill-opacity='.035'/%3E%3C/svg%3E");
  --m-tex-size: 16px 10px, 16px 10px, auto; --m-tex-rep: repeat-x, repeat-x, repeat; --m-tex-pos: 2px 2px, 2px calc(100% - 2px), 0 0;   /* a rivet row along the top and the bottom */
  --m-r: 4px; --m-r-sm: 3px;
  --m-edge: 4px double;
  --m-rim: inset 0 2px 0 rgba(255, 255, 255, .05);
  --m-ctl-tex: repeating-linear-gradient(90deg, rgba(0, 0, 0, .2) 0 2px, rgba(255, 255, 255, .04) 2px 3px, transparent 3px 7px);
  --m-ctl-rim: inset 0 1px 0 rgba(255, 255, 255, .08), 0 2px 0 rgba(0, 0, 0, .35);
  --m-on: 0 2px 0 var(--bag-shadow);
  --m-in-bg: #182838; --m-in-ink: var(--ink); --m-in-edge: #6a8aa6; --m-in-scheme: dark;
  --m-in-tex: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath d='M2 3h1v1H2zM9 8h1v1H9zM5 10h1v1H5z' fill='%23d8543a' fill-opacity='.12'/%3E%3C/svg%3E");   /* a speck of rust */
}
:root[data-theme="beach"] {   /* sun-bleached driftwood, soft round corners, coral pebble chips; sandy paper to write on */
  --m-tex: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='18'%3E%3Cpath d='M0 4q30-3 60 0t60 0M0 11q40 3 70 0t50 1M0 16q25-2 55 0t65-1' fill='none' stroke='%23fff' stroke-opacity='.06'/%3E%3C/svg%3E");
  --m-tex-size: 120px 18px;
  --m-r: 20px; --m-r-sm: 999px;
  --m-rim: inset 0 1px 0 rgba(255, 255, 255, .1), 0 6px 18px rgba(0, 20, 30, .25);
  --m-ctl-tex: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, .12), transparent 60%);
  --m-ctl-rim: 0 2px 6px rgba(0, 20, 30, .3);
  --m-on: 0 0 0 2px var(--bag-light), 0 3px 8px rgba(0, 0, 0, .3);
  --m-in-bg: #f2e2bc; --m-in-ink: #3a2a14; --m-in-edge: #e8d2a2; --m-in-scheme: light;
  --m-in-tex: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='9'%3E%3Cpath d='M1 1h1v1H1zM5 3h1v1H5zM3 7h1v1H3zM7 6h1v1H7z' fill='%238a6a3a' fill-opacity='.2'/%3E%3C/svg%3E");
}

/* ---------- panels */
.card, .bar, .tile, .sheet, #chat-dock .chat-panel, #chat-dock .chat-pop {
  background-image: var(--m-tex); background-size: var(--m-tex-size); background-repeat: var(--m-tex-rep, repeat); background-position: var(--m-tex-pos, 0 0);
  border-radius: var(--m-r); }
.card, .bar, .sheet, #chat-dock .chat-pop { border: var(--m-edge) var(--panel-edge); box-shadow: var(--m-rim), 0 8px 24px rgba(0, 0, 0, .3); }
.tile { box-shadow: inset 0 0 0 1px var(--wood-line), var(--m-rim); }
.sheet { box-shadow: var(--m-rim), 0 20px 60px rgba(0, 0, 0, .55); }
#chat-dock .chat-panel { border-top: var(--m-edge) var(--panel-edge); border-radius: var(--m-r) var(--m-r) 0 0; box-shadow: var(--m-rim), 0 -6px 24px rgba(0, 0, 0, .5); }
@media (min-width: 900px) { #chat-dock .chat-panel { border: var(--m-edge) var(--panel-edge); border-radius: var(--m-r); } }
.chat-panel header, .chatui .quick, .tabs, .sheet h3 { border-color: color-mix(in srgb, var(--panel-edge) 45%, var(--wood-line)); }

/* ---------- controls */
.chip, .chatui .chan button, .gear, .seg, .chatui .cheats button, #chat-dock .chat-btn {
  background-image: var(--m-ctl-tex); box-shadow: var(--m-ctl-rim); }
.chip, .chatui .chan button, .gear, .chatui .send { border-radius: var(--m-r-sm); }
#chat-dock .chat-btn { border: var(--m-edge) var(--panel-edge); }
.chip[aria-pressed="true"], .chatui .chan button[aria-selected="true"], .seg-b[aria-pressed="true"] { box-shadow: var(--m-on); }
.big { border-radius: var(--m-r); background-image: var(--m-ctl-tex), linear-gradient(var(--bag-light), var(--bag)); }
.big.alt { background-image: var(--m-ctl-tex), linear-gradient(var(--alt-light), var(--alt)); }
.big.lock { background-image: var(--m-ctl-tex), linear-gradient(var(--go-light), var(--go)); }
.tab { border-radius: var(--m-r-sm) var(--m-r-sm) 0 0; }
:root[data-theme="beach"] .tab { border-radius: 12px 12px 0 0; }

/* what you type on */
input:not([type="checkbox"]):not([type="radio"]), select, .chatui input, .sheet input:not([type]), .sheet select {
  background-color: var(--m-in-bg); background-image: var(--m-in-tex); color: var(--m-in-ink); border-color: var(--m-in-edge);
  border-radius: var(--m-r-sm); color-scheme: var(--m-in-scheme); }
:root[data-theme="beach"] :is(input, select) { border-radius: 12px; }
input::placeholder { color: color-mix(in srgb, var(--m-in-ink) 50%, transparent); }
.chat-panel[data-chan="team"] input { border-color: var(--go); }

/* headings in the theme's letters */
.sheet h2, .card h2, .bar .team-name { font-family: var(--m-head); }
:root[data-theme="japan"] :is(.sheet h2, .card h2, .bar .team-name) { font-weight: 800; letter-spacing: .5px; }

/* the moment after a change: the sheet's footer says it was saved */
.sheet .note.saved { color: var(--go); transition: color .3s; }
