/* Jahaklan — the print shop: clean workshop UI, honest A4 pages. */

:root {
  --paper: #efe6d3;
  --ink: #2c2013;
  --ink-soft: #6b5540;
  --laterite: #9c3b22;
  --indigo: #29457c;
  --gold: #d9a441;
  --line: #cbbc9d;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

body {
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: "Nunito", system-ui, sans-serif;
  padding-bottom: 90px;
}

[lang^="dux"] { font-family: "Andika", sans-serif; }

#top { padding: max(16px, env(safe-area-inset-top)) 20px 8px; }
#top h1 { font-size: 1.75rem; font-weight: 400; color: var(--laterite); font-family: "Andika", sans-serif; }
#top h1 .sub { display: block; font-family: "Nunito", sans-serif; font-size: 0.8rem; font-weight: 800; color: var(--ink-soft); }

#tabs { display: flex; gap: 8px; padding: 8px 18px 4px; }

.tab {
  border: 1.5px solid var(--line);
  background: #f7f0e0;
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 9px 15px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
}

.tab.active { background: var(--indigo); border-color: var(--indigo); color: #fff; }

#options {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding: 10px 18px 2px;
  align-items: center;
}

#options label { font-size: 0.85rem; font-weight: 800; color: var(--ink-soft); }

#options select {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink);
}

#hint { padding: 8px 20px; font-size: 0.8rem; font-weight: 700; color: var(--ink-soft); }

/* ---------- pages ---------- */

#preview { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 8px 12px 30px; }

.page {
  width: min(94vw, 560px);
  aspect-ratio: 210 / 297;
  background: #fff;
  box-shadow: 0 8px 30px rgba(44, 32, 19, 0.25);
  padding: 4.2% 4.6%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page-head { text-align: center; margin-bottom: 2%; }
.page-head .t { font-family: "Andika", sans-serif; font-size: clamp(15px, 4.4vw, 26px); color: var(--laterite); font-weight: 700; }
.page-head .s { font-size: clamp(8px, 2vw, 12px); font-weight: 800; color: var(--ink-soft); letter-spacing: 0.12em; text-transform: uppercase; }

/* poster */
.alpha-grid { flex: 1; display: grid; grid-template-columns: repeat(5, 1fr); gap: 1.6%; }

.alpha-cell {
  border: 1.5px solid var(--line);
  border-radius: 8%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2%;
  min-height: 0;
}

.alpha-cell .L { font-family: "Andika", sans-serif; font-size: clamp(14px, 4.6vw, 30px); line-height: 1.05; color: var(--indigo); font-weight: 700; }
.alpha-cell .w { font-family: "Andika", sans-serif; font-size: clamp(7px, 1.9vw, 12px); color: var(--ink); margin-top: 2%; text-align: center; overflow-wrap: anywhere; }
.alpha-cell .g { font-size: clamp(6px, 1.5vw, 9px); color: var(--ink-soft); font-weight: 700; text-align: center; }

.page-foot { text-align: center; font-size: clamp(6px, 1.6vw, 10px); font-weight: 700; color: var(--ink-soft); margin-top: 1.5%; }

/* flashcards */
.cards-grid { flex: 1; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: repeat(4, 1fr); gap: 0; }

.fcard {
  border: 1px dashed #b9a883;
  display: flex;
  align-items: center;
  gap: 4%;
  padding: 3%;
  min-height: 0;
}

.fcard img { height: 84%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; }
.fcard .fc-txt { min-width: 0; }
.fcard .w { font-family: "Andika", sans-serif; font-size: clamp(11px, 3.4vw, 20px); font-weight: 700; color: var(--ink); overflow-wrap: anywhere; line-height: 1.1; }
.fcard .g { font-size: clamp(7px, 1.9vw, 11px); font-weight: 700; color: var(--ink-soft); }

/* writing sheet */
.write-rows { flex: 1; display: flex; flex-direction: column; gap: 1%; }

.write-row {
  flex: 1;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  gap: 4%;
  font-family: "Andika", sans-serif;
  font-size: clamp(20px, 7vw, 44px);
  padding: 0 2%;
  min-height: 0;
  overflow: hidden;
}

.write-row .model { color: var(--ink); font-weight: 700; }
.write-row .trace { color: rgba(44, 32, 19, 0.22); letter-spacing: 0.35em; }

/* ---------- print button ---------- */

#print-btn {
  position: fixed;
  bottom: calc(52px + env(safe-area-inset-bottom));
  right: 16px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 0;
  border-radius: 999px;
  background: var(--laterite);
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 800;
  padding: 14px 22px;
  box-shadow: 0 8px 24px rgba(156, 59, 34, 0.45);
  cursor: pointer;
  z-index: 30;
}

#print-btn svg { width: 20px; height: 20px; }

#foot {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: 9px 18px calc(9px + env(safe-area-inset-bottom));
  background: rgba(239, 230, 211, 0.96);
  border-top: 1.5px solid var(--line);
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--ink-soft);
}

#foot a { color: var(--laterite); text-decoration: none; }

/* ---------- print ---------- */

@media print {
  .no-print { display: none !important; }
  body { background: #fff; padding: 0; }
  #preview { padding: 0; gap: 0; display: block; }
  .page {
    width: 100%;
    height: 100vh;
    aspect-ratio: auto;
    box-shadow: none;
    page-break-after: always;
    break-after: page;
  }
}
