/* FARM LIFE ONLINE: the wiki, patch notes and legal pages, dressed in the game's own HD UI kit (the Product Lead,
   2026-10-01: "ชุด UI ในเว็บ ใช้ชุดเดียวกับในเกม"). The kit is src/ui/kit_hd (copied into /wiki-assets/ at build) with the
   game's slices (src/ui/kit_hd/slices.json): the dark wood window (panel), the red ribbon title, the paper plate and
   slot, the wood and red buttons; the game's font and colour tokens (src/ui/style.css). The pages sit over the title
   art, like the game's windows over the village. */
@font-face { font-family: SOV; src: url('/wiki-assets/SOV_BokThang.ttf') format('truetype'); font-display: swap; }

:root {
  --paper: #f4ede0;
  --parchment-light: #f6ecc9;
  --ink: #221a16;
  --ink-soft: #3a2b28;
  --soil-dark: #3b2418;
  --wood-dark: #4a2f1e;
  --wood-mid: #6e4a2f;
  --wood-pale: #c39a5e;
  --wood-pale-2: #e5c98a;
  --accent-red: #b3202a;
  --accent-yellow: #ffd23f;
  --success: #4a7d31;
  --ui-font: SOV, 'Leelawadee UI', Tahoma, sans-serif;
  --read-font: 'Leelawadee UI', 'Noto Sans Thai', 'Sarabun', Tahoma, sans-serif;
}
* { box-sizing: border-box; }
html { color: var(--paper); background: var(--soil-dark); font-family: var(--ui-font); font-size: 20px; line-height: 1.7; scrollbar-color: #d69644 #3c2618; }
body {
  margin: 0; min-height: 100vh;
  background: linear-gradient(rgba(24, 12, 5, 0.78), rgba(24, 12, 5, 0.86)), url('/wiki-assets/hero.webp') center / cover fixed, var(--soil-dark);
}
img { max-width: 100%; height: auto; }
a { color: var(--accent-yellow); text-underline-offset: 4px; overflow-wrap: anywhere; }
a:hover { color: #fff1a8; }
a:focus-visible, .btn:focus-visible { outline: 3px solid var(--accent-yellow); outline-offset: 3px; }
p { margin: 10px 0; }
ul, ol { padding-left: 24px; }
li { margin: 4px 0; }
strong { color: var(--wood-pale-2); font-weight: normal; }
.skip { position: absolute; left: 16px; top: -100px; background: var(--paper); color: var(--ink); padding: 12px; z-index: 30; }
.skip:focus { top: 12px; }

/* --- The kit: buttons (slice 14) ------------------------------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 52px; padding: 0 12px;
  border-style: solid; border-width: 14px;
  border-image: url('/wiki-assets/btn.webp') 14 fill / 14px stretch;
  color: var(--ink); text-decoration: none; font-family: var(--ui-font); font-size: 22px; line-height: 1; white-space: nowrap;
}
.btn:hover { color: var(--ink); border-image-source: url('/wiki-assets/btn_hover.webp'); }
.btn:active { border-image-source: url('/wiki-assets/btn_down.webp'); }
.btn-go { border-image-source: url('/wiki-assets/btn_go.webp'); color: var(--paper); text-shadow: 0 2px 0 rgba(60, 8, 8, 0.6); }
.btn-go:hover { color: #fff; border-image-source: url('/wiki-assets/btn_go.webp'); filter: brightness(1.08); }
.btn-go:active { border-image-source: url('/wiki-assets/btn_go_down.webp'); }
.btn-small { min-height: 44px; border-width: 12px; border-image-width: 12px; padding: 0 6px; font-size: 19px; }

/* --- The kit: the window (panel, slice 56), the ribbon (0 54), paper (16) and slot paper ------------------------------ */
.card, .topic-card, .release {
  position: relative; min-width: 0;
  padding: 10px 14px 12px;
  border-style: solid; border-width: 28px;
  border-image: url('/wiki-assets/panel.webp') 56 fill / 28px stretch;
  color: var(--paper);
}
.card > h2:first-child {
  display: flex; align-items: center; gap: 12px; margin: -2px 0 12px; padding: 0 0 8px;
  color: var(--accent-yellow); font-size: 24px; line-height: 1.3; text-shadow: 0 2px 0 rgba(20, 8, 2, 0.8);
  border-bottom: 2px solid rgba(195, 154, 94, 0.45);
}
.card > h2:first-child::before { content: ''; flex: none; width: 10px; height: 10px; transform: rotate(45deg); background: var(--wood-pale-2); box-shadow: 0 0 0 2px var(--wood-dark); }
/* The red ribbon (455 x 68 art) keeps its own height: only the middle stretches sideways, and a long title is cut with an ellipsis. */
.ribbon {
  display: inline-flex; align-items: center; height: 46px; max-width: 100%; margin: 0 0 10px; padding: 0 8px 5px;
  border-style: solid; border-width: 0 34px; border-image: url('/wiki-assets/ribbon.webp') 0 54 fill / 0 34px stretch;
  color: var(--paper); font-size: 22px; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 2px 0 rgba(40, 6, 6, 0.7);
}
.paper {
  color: var(--ink);
  border-style: solid; border-width: 16px;
  border-image: url('/wiki-assets/plate_paper.webp') 16 fill / 16px stretch;
}
.paper a { color: #7a2a14; }
.paper strong { color: var(--ink); }

/* --- Header and footer: the game's dark soil bar --------------------------------------------------------------------- */
.site-header { position: sticky; top: 0; z-index: 20; background: var(--soil-dark); border-bottom: 4px solid var(--wood-pale); box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35); }
.header-inner { max-width: 1160px; margin: auto; padding: 6px 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px 24px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-logo { width: 132px; height: auto; display: block; image-rendering: pixelated; }
.brand-label { font-size: 22px; color: var(--accent-yellow); text-shadow: 0 2px 0 #120904; }
.site-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 22px; }
.site-nav a:not(.btn) { color: var(--paper); text-decoration: none; font-size: 21px; padding: 4px 0; border-bottom: 3px solid transparent; }
.site-nav a:not(.btn):hover, .site-nav a[aria-current='page'] { color: var(--accent-yellow); border-bottom-color: var(--accent-yellow); }

/* --- The search box (TASK-151): in the header, with a paper dropdown of results ------------------------------------------- */
.site-search { position: relative; flex: 1 1 260px; max-width: 440px; min-width: 0; }
.site-search input {
  display: block; width: 100%; min-height: 46px; padding: 6px 14px;
  font-family: var(--ui-font); font-size: 20px; line-height: 1.3; color: var(--paper);
  background: #24140a; border: 3px solid var(--wood-pale); border-radius: 0; box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.45);
  appearance: none; -webkit-appearance: none;
}
.site-search input::placeholder { color: var(--wood-pale); opacity: 1; }
.site-search input:focus { outline: 3px solid var(--accent-yellow); outline-offset: 2px; border-color: var(--accent-yellow); }
.site-search input::-webkit-search-cancel-button { filter: sepia(1) brightness(1.6); height: 20px; width: 20px; }
.sr-list { list-style: none; margin: 0; padding: 0; }
.sr-drop {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 40; max-height: min(70vh, 560px); overflow-y: auto;
  background: var(--paper); color: var(--ink); border: 4px solid var(--wood-pale); box-shadow: 0 6px 0 rgba(0, 0, 0, 0.45);
}
.sr-item { margin: 0; border-bottom: 2px solid rgba(110, 74, 47, 0.3); }
.sr-item:last-child { border-bottom: 0; }
.sr-link { display: block; padding: 8px 12px; min-height: 44px; color: var(--ink); text-decoration: none; }
.sr-link:hover, .sr-active .sr-link { background: var(--wood-pale-2); color: var(--ink); }
.sr-title { display: inline; font-size: 21px; color: var(--accent-red); }
.sr-section { display: inline-block; margin-left: 8px; padding: 0 8px; font-size: 16px; line-height: 1.5; color: var(--paper); background: var(--wood-mid); }
.sr-snippet { display: block; margin-top: 2px; font-family: var(--read-font); font-size: 15px; line-height: 1.5; color: var(--ink-soft); overflow-wrap: anywhere; }
.sr-title mark, .sr-snippet mark { background: var(--accent-yellow); color: var(--ink); padding: 0 1px; }
.sr-empty { padding: 12px 14px; font-size: 19px; color: var(--ink-soft); }
.sr-page { margin: 16px 0; background: var(--paper); color: var(--ink); border: 4px solid var(--wood-pale); }
.sr-page:empty { display: none; }
.site-footer { background: var(--soil-dark); border-top: 4px solid var(--wood-pale); }
.footer-inner { max-width: 1160px; margin: auto; padding: 18px 16px 24px; }
.footer-inner nav { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.footer-inner a { color: var(--wood-pale-2); }
.footer-inner p { font-size: 16px; color: var(--wood-pale); margin: 10px 0 0; }

/* --- Hero (home) ----------------------------------------------------------------------------------------------------- */
.hero { position: relative; display: grid; place-items: center; min-height: 470px; padding: 40px 16px 48px; background: url('/wiki-assets/hero.webp') center 35% / cover no-repeat; border-bottom: 4px solid var(--wood-pale); }
.hero::before { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(20, 10, 4, 0.1) 0%, rgba(20, 10, 4, 0.5) 70%, rgba(20, 10, 4, 0.8) 100%); }
.hero-inner { position: relative; text-align: center; max-width: 820px; }
.hero-logo { width: 440px; max-width: 86vw; image-rendering: pixelated; filter: drop-shadow(0 6px 0 rgba(0, 0, 0, 0.35)); }
.hero-tagline { font-size: 26px; line-height: 1.5; color: var(--paper); text-shadow: 0 2px 0 #120904, 0 0 12px rgba(0, 0, 0, 0.6); margin: 8px 0 20px; }
.hero-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }

/* --- Page frame ------------------------------------------------------------------------------------------------------ */
/* One column of reading width on every screen (about 80 Thai characters a line), the title and the cards aligned to it; the home page keeps the wider grid. */
main { max-width: 1000px; margin: auto; padding: 24px 16px 56px; min-height: 60vh; }
body:has(.hero) main { max-width: 1160px; }
article { min-width: 0; }
article > * { max-width: 100%; }
.breadcrumb { margin: 0; font-size: 17px; }
.breadcrumb a { color: var(--wood-pale-2); }
.page-title { margin-bottom: 18px; }
.page-title h1 { display: inline-flex; align-items: center; height: 66px; max-width: 100%; margin: 0; padding: 0 12px 8px; border-style: solid; border-width: 0 48px; border-image: url('/wiki-assets/ribbon.webp') 0 54 fill / 0 48px stretch; color: var(--paper); font-size: 36px; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 3px 0 rgba(40, 6, 6, 0.7); }
h1, h2, h3 { font-family: var(--ui-font); font-weight: normal; line-height: 1.4; overflow-wrap: anywhere; }
h1 { font-size: 40px; }
h2 { font-size: 26px; margin: 26px 0 10px; color: var(--accent-yellow); }
h3 { font-size: 22px; margin: 16px 0 6px; color: var(--wood-pale-2); }
.lead { font-size: 21px; color: var(--wood-pale-2); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 30px 0 14px; }
.section-head h2 { margin: 0; display: inline-flex; align-items: center; height: 52px; max-width: 100%; white-space: nowrap; line-height: 1; padding: 0 8px 6px; border-style: solid; border-width: 0 40px; border-image: url('/wiki-assets/ribbon.webp') 0 54 fill / 0 40px stretch; color: var(--paper); font-size: 25px; text-shadow: 0 2px 0 rgba(40, 6, 6, 0.7); }
.section-head a { font-size: 21px; }

/* Cards and grids */
article > .card { margin: 18px 0; }
.cards, .card-grid, .topic-grid, .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 16px; }
.card-grid > .card { margin: 0; }
.card-grid a.card { text-decoration: none; transition: transform 0.12s; }
.card-grid a.card:hover { transform: translateY(-3px); }
.card-grid a.card h2 { font-size: 22px; }
.notice, .draft, blockquote {
  margin: 16px 0; padding: 4px 8px; color: var(--ink);
  border-style: solid; border-width: 16px; border-image: url('/wiki-assets/plate_paper.webp') 16 fill / 16px stretch;
}
blockquote p, .notice { margin-top: 0; margin-bottom: 0; }
blockquote p { font-weight: normal; }

/* Screenshots: framed like the game's windows */
.shot { margin: 0 0 20px; }
.shot img, .feature-shot img { display: block; width: 100%; border: 6px solid var(--wood-dark); outline: 3px solid var(--wood-pale); outline-offset: -9px; border-radius: 6px; box-shadow: 0 6px 0 rgba(0, 0, 0, 0.35); background: var(--soil-dark); }
.shot figcaption { margin-top: 8px; font-size: 17px; color: var(--wood-pale-2); text-align: center; }
.shot-topic img { max-height: 470px; object-fit: cover; }

/* --- Home ------------------------------------------------------------------------------------------------------------ */
.news-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 16px; }
.news-item {
  display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--ink);
  padding: 6px 10px; border-style: solid; border-width: 16px; border-image: url('/wiki-assets/plate_paper.webp') 16 fill / 16px stretch;
  transition: transform 0.12s;
}
.news-item:hover { color: var(--ink); transform: translateY(-3px); }
.news-item strong { font-size: 23px; line-height: 1.35; color: var(--ink); }
.news-item > span:last-child { color: var(--ink-soft); font-family: var(--read-font); font-size: 16px; }
.news-date { font-size: 16px; color: var(--ink-soft); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge { display: inline-block; padding: 0 8px; border-radius: 3px; font-size: 15px; line-height: 1.6; }
.badge-new { background: var(--accent-red); color: var(--paper); }

.features { display: flex; flex-direction: column; gap: 22px; margin: 34px 0; }
.feature {
  display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; align-items: center;
  padding: 6px 10px; border-style: solid; border-width: 28px; border-image: url('/wiki-assets/panel.webp') 56 fill / 28px stretch;
}
.feature:nth-child(even) { grid-template-columns: 1fr 1.3fr; }
.feature:nth-child(even) .feature-shot { order: 2; }
.feature-shot img { transition: transform 0.15s; }
.feature-shot:hover img { transform: scale(1.012); }
.feature-text h2 { margin: 0 0 4px; font-size: 30px; color: var(--accent-yellow); }
.feature-text p { font-size: 20px; color: var(--paper); }
.more { font-size: 21px; text-decoration: none; }
.more::after { content: ' >'; }

.topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 16px; }
.topic {
  display: flex; flex-direction: column; overflow: hidden; text-decoration: none; color: var(--ink);
  border-style: solid; border-width: 16px; border-image: url('/wiki-assets/slot_paper.webp') 22 fill / 16px stretch;
  transition: transform 0.12s;
}
.topic:hover { color: var(--ink); transform: translateY(-3px); }
.topic-thumb { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border: 3px solid var(--wood-mid); border-radius: 3px; }
.topic-thumb-plain { background: url('/icons/app-192.png') center / 88px no-repeat, linear-gradient(160deg, var(--wood-mid), var(--soil-dark)); }
.topic-body { display: flex; flex-direction: column; gap: 0; padding: 8px 2px 2px; }
.topic-body strong { font-size: 22px; color: var(--ink); line-height: 1.35; }
.topic-body span { font-family: var(--read-font); font-size: 15px; color: var(--ink-soft); line-height: 1.5; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 16px; margin-top: 30px; }

/* --- Patch notes ----------------------------------------------------------------------------------------------------- */
.release-toc { padding: 6px 10px; border-style: solid; border-width: 16px; border-image: url('/wiki-assets/plate_paper.webp') 16 fill / 16px stretch; }
.release-toc ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; }
.release-toc a { display: flex; gap: 14px; flex-wrap: wrap; text-decoration: none; padding: 4px 6px; color: var(--ink); border-radius: 3px; }
.release-toc a:hover { background: rgba(122, 42, 20, 0.12); color: var(--ink); }
.release-toc span { color: #7a2a14; min-width: 64px; }
.releases { display: flex; flex-direction: column; gap: 22px; margin-top: 22px; }
.release { scroll-margin-top: 90px; }
.release h2 { margin: 2px 0 2px; font-size: 30px; }
.release h2 .anchor { color: var(--accent-yellow); text-decoration: none; }
.release-date { margin: 0; font-size: 17px; color: var(--wood-pale-2); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.release-version { color: var(--ink); background: var(--wood-pale-2); padding: 0 10px; border-radius: 3px; }
.release-summary { font-size: 20px; color: var(--paper); margin: 0 0 12px; }
.shot-release img { max-height: 420px; object-fit: cover; }
.shot-release figcaption { display: none; }

/* --- Data pages ------------------------------------------------------------------------------------------------------ */
.portrait { display: block; max-width: 144px; margin: 0 0 14px; image-rendering: pixelated; border: 4px solid var(--wood-pale); border-radius: 4px; background: var(--parchment-light); }
.card-grid .portrait { border-width: 3px; }
.stages, .crop-stages { display: flex; gap: 14px; flex-wrap: wrap; align-items: end; padding: 10px; background: rgba(0, 0, 0, 0.18); border-radius: 4px; }
.stage, .crop-stage { flex-shrink: 0; image-rendering: pixelated; max-width: none; }
.stage-label { font-size: 15px; }
.crop-stages figure { margin: 0; max-width: 100%; text-align: center; }
.crop-stages figcaption { font-size: 15px; line-height: 1.5; color: var(--wood-pale-2); }
table { width: 100%; border-collapse: collapse; font-size: 17px; color: var(--paper); }
th, td { text-align: left; vertical-align: top; padding: 8px 10px; border: 1px solid var(--wood-mid); overflow-wrap: anywhere; }
th { background: var(--wood-dark); color: var(--accent-yellow); font-weight: normal; }
td img { max-width: 96px; image-rendering: pixelated; }
.item-icon { display: inline-block; width: 32px; height: 32px; margin: 0 8px 0 0; vertical-align: middle; image-rendering: pixelated; }
.machine-art { display: block; margin: 0 0 12px; max-width: 100%; image-rendering: pixelated; }
dl { margin: 10px 0; }
dt { color: var(--accent-yellow); }
dd { margin: 0 0 10px; }

/* --- Teaching blocks (TASK-140): steps, tips, pitfalls, key numbers, the page's contents ---------------------------- */
ol.steps { list-style: none; counter-reset: step; padding: 0; margin: 8px 0; }
ol.steps > li { counter-increment: step; position: relative; padding: 4px 0 4px 52px; margin: 8px 0; min-height: 38px; }
ol.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 2px; width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 50%; background: var(--accent-red); color: var(--paper); font-size: 20px; line-height: 1;
  box-shadow: 0 0 0 3px var(--wood-pale), 0 3px 0 3px rgba(0, 0, 0, 0.35);
}
.tip, .warn { margin: 12px 0; padding: 10px 14px 10px 52px; position: relative; border-radius: 6px; font-size: 18px; }
.tip { background: rgba(74, 125, 49, 0.22); border: 2px solid rgba(124, 180, 84, 0.6); }
.warn { background: rgba(179, 32, 42, 0.18); border: 2px solid rgba(220, 90, 70, 0.6); }
.tip::before, .warn::before { position: absolute; left: 12px; top: 8px; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; font-size: 18px; line-height: 1; }
.tip::before { content: '\2713'; background: var(--success); color: var(--paper); }
.warn::before { content: '!'; background: var(--accent-red); color: var(--paper); }
dl.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 10px; margin: 8px 0; }
dl.facts > div { padding: 8px 12px; background: rgba(0, 0, 0, 0.22); border: 1px solid var(--wood-mid); border-radius: 6px; }
dl.facts dt { font-size: 16px; color: var(--wood-pale-2); }
dl.facts dd { margin: 0; font-size: 24px; color: var(--accent-yellow); line-height: 1.3; }
nav.toc { margin: 0 0 18px; }
nav.toc ul { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; }
nav.toc li { margin: 0; }
nav.toc a { padding: 4px 12px; border-radius: 999px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--wood-pale); color: var(--paper); text-decoration: none; font-size: 17px; }
nav.toc a:hover { background: var(--wood-mid); color: var(--accent-yellow); }
.card[id] { scroll-margin-top: 100px; }
.table-wrap { overflow-x: auto; }

/* --- Legal: the same window, a reading font for long text ---------------------------------------------------------- */
.legal article { max-width: 900px; margin: 0 auto; padding: 10px 16px 16px; border-style: solid; border-width: 28px; border-image: url('/wiki-assets/panel.webp') 56 fill / 28px stretch; font-family: var(--read-font); font-size: 17px; line-height: 1.85; }
.legal article h2 { font-family: var(--ui-font); }
.legal article h3 { font-family: var(--ui-font); }
.legal blockquote p { font-family: var(--ui-font); font-size: 19px; }

/* --- Phones ---------------------------------------------------------------------------------------------------------- */
@media (max-width: 760px) {
  html { font-size: 18px; }
  .site-header { position: static; }
  .brand-logo { width: 104px; }
  .site-nav { gap: 2px 16px; }
  .site-search { order: 3; flex-basis: 100%; max-width: none; }
  .site-search input { min-height: 48px; }
  .site-nav a:not(.btn) { font-size: 19px; }
  .hero { min-height: 340px; padding: 26px 16px 32px; }
  .hero-tagline { font-size: 20px; }
  .btn { font-size: 19px; min-height: 46px; border-width: 12px; border-image-width: 12px; }
  h1 { font-size: 30px; }
  .page-title h1 { border-width: 0 36px; border-image-width: 0 36px; height: 54px; font-size: 28px; }
  .card > h2:first-child { font-size: 21px; }
  dl.facts { grid-template-columns: 1fr 1fr; }
  h2 { font-size: 23px; }
  .card, .topic-card, .release, .feature, .legal article { border-width: 20px; border-image-width: 20px; }
  .feature, .feature:nth-child(even) { grid-template-columns: 1fr; gap: 10px; }
  .feature:nth-child(even) .feature-shot { order: 0; }
  .feature-text h2 { font-size: 25px; }
  table, tbody, tr, td, th { display: block; }
  thead { display: none; }
  tr { margin: 14px 0; border: 2px solid var(--wood-mid); }
  td, th { border: 0; border-bottom: 1px solid var(--wood-mid); }
  td[data-label]::before { content: attr(data-label) ': '; color: var(--accent-yellow); }
  .portrait { margin: 0 auto 14px; }
}
