/* Page frame of the "Maktab daftari" design: cover, paper, margin, footer. */

/* Self-hosted subsets, see app/static/fonts/README.md. The ?v= value is the file's
   content hash; tests/web/test_static_assets.py fails when it is out of date. */
@font-face {
  font-family: "Andika";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/andika-uz-400.woff2?v=32ae432119") format("woff2");
  unicode-range: U+0020-007E, U+00A0, U+00A9, U+00AB, U+00B0, U+00B7, U+00BB, U+00C7, U+00D6, U+00E7,
    U+00F6, U+011E-011F, U+015E-015F, U+02BB-02BC, U+2013-2014, U+2018-2019, U+201C-201D,
    U+2026, U+2116;
}

@font-face {
  font-family: "Andika";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/andika-cyrillic-400.woff2?v=993ee9831a") format("woff2");
  unicode-range: U+0401, U+0410-044F, U+0451;
}

@font-face {
  font-family: "Andika";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/andika-uz-700.woff2?v=e3d1f92cc0") format("woff2");
  unicode-range: U+0020-007E, U+00A0, U+00A9, U+00AB, U+00B0, U+00B7, U+00BB, U+00C7, U+00D6, U+00E7,
    U+00F6, U+011E-011F, U+015E-015F, U+02BB-02BC, U+2013-2014, U+2018-2019, U+201C-201D,
    U+2026, U+2116;
}

@font-face {
  font-family: "Andika";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/andika-cyrillic-700.woff2?v=2c479ca315") format("woff2");
  unicode-range: U+0401, U+0410-044F, U+0451;
}

@font-face {
  font-family: "Playpen Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/playpen-sans-uz-400.woff2?v=7d8f735401") format("woff2");
  unicode-range: U+0020-007E, U+00A0, U+00A9, U+00AB, U+00B0, U+00B7, U+00BB, U+00C7, U+00D6, U+00E7,
    U+00F6, U+011E-011F, U+015E-015F, U+02BB-02BC, U+2013-2014, U+2018-2019, U+201C-201D,
    U+2026, U+2116;
}

@font-face {
  font-family: "Playpen Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/playpen-sans-cyrillic-400.woff2?v=0723e6470c") format("woff2");
  unicode-range: U+0401, U+0410-044F, U+0451;
}

@font-face {
  font-family: "Playpen Sans";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/playpen-sans-uz-700.woff2?v=0653f823aa") format("woff2");
  unicode-range: U+0020-007E, U+00A0, U+00A9, U+00AB, U+00B0, U+00B7, U+00BB, U+00C7, U+00D6, U+00E7,
    U+00F6, U+011E-011F, U+015E-015F, U+02BB-02BC, U+2013-2014, U+2018-2019, U+201C-201D,
    U+2026, U+2116;
}

@font-face {
  font-family: "Playpen Sans";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/playpen-sans-cyrillic-700.woff2?v=79b66d47ac") format("woff2");
  unicode-range: U+0401, U+0410-044F, U+0451;
}

:root {
  --on-cover: #FFFFFF;
  --label: #FFFFFF;
  /* The pale blue of a printed exercise-book band; carries the demo notes. */
  --ribbon: #E9EEF8;
  /* Grid lines drawn at 60%, so the paper stays quiet behind the text. */
  --grid-line: color-mix(in srgb, var(--grid) 60%, transparent);
  /* Table rules: the grid blue, darker, so cells stay apart on white. */
  --table-line: #9FB3DC;
  --rule-width: 2px;
  --margin-width: calc(var(--cell) * 3);
  --content-inset: calc(var(--margin-width) + var(--rule-width) + var(--cell) / 2);
  --touch-target: 44px;
  --text-scale: 1;
  --line-length: 72ch;
  /* 15px, 14px, 13px and 12px at the 17px body size. */
  --size-menu: 0.882rem;
  --size-note: 0.8235rem;
  --size-small: 0.765rem;
  --size-tiny: 0.706rem;
}

@media (min-width: 600px) {
  :root {
    --margin-width: calc(var(--cell) * 4);
  }
}

/* Low-vision settings, written on <html> by the accessibility panel. */
html[data-a11y-size="large"] {
  --text-scale: 1.25;
}

html[data-a11y-size="larger"] {
  --text-scale: 1.5;
}

html[data-a11y-theme="contrast"] {
  --paper: #FFFFFF;
  --grid: transparent;
  --ink: #000000;
  --red-pen: #000000;
  --cover: #000000;
  --pencil: #000000;
  --font-hand: var(--font-text);
}

html[data-a11y-images="off"] img {
  display: none;
}

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

/* Layout rules below set display on buttons and links; [hidden] must still win. */
[hidden] {
  display: none !important;
}

html {
  /* 106.25% of the browser's 16px default is the 17px body size, and it follows the user's own setting. */
  font-size: calc(106.25% * var(--text-scale));
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 1rem;
  /* 24px, one cell, at the default text size. */
  line-height: 1.4118;
  overflow-wrap: break-word;
}

h1,
h2,
h3 {
  margin: 0 0 var(--cell);
  font-family: var(--font-hand);
  font-weight: 700;
  line-height: 1.25;
}

h1 {
  font-size: 1.75rem;
}

h2 {
  font-size: 1.35rem;
}

h3 {
  font-size: 1.1rem;
}

p,
ul,
ol {
  margin: 0 0 var(--cell);
}

p,
li {
  max-width: var(--line-length);
}

a {
  color: var(--ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

.cover :focus-visible {
  outline-color: var(--on-cover);
}

/* Skip link: off screen until it receives keyboard focus. */
.skip-link {
  position: absolute;
  top: calc(var(--cell) * -4);
  left: var(--cell);
  z-index: 10;
  padding: 0 calc(var(--cell) / 2);
  background: var(--label);
  color: var(--ink);
  line-height: calc(var(--cell) * 2);
}

.skip-link:focus {
  top: calc(var(--cell) / 2);
}

/* A pencilled note above the cover: the data on the page is not real. */
.demo-ribbon {
  max-width: none;
  margin: 0;
  padding: calc(var(--cell) / 6) calc(var(--cell) * 2 / 3);
  background: var(--ribbon);
  color: var(--pencil);
  font-size: var(--size-small);
  line-height: 1.5385;
}

/* Cover: header and footer, the green card of the exercise book. */
.cover {
  background: var(--cover);
  color: var(--on-cover);
}

.cover a {
  color: var(--on-cover);
}

.cover ul {
  display: flex;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cover-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: calc(var(--cell) / 3) calc(var(--cell) / 2);
  padding: calc(var(--cell) * 2 / 3);
}

/* The white name label glued on the cover, ruled like the page inside. */
.school-label {
  display: block;
  flex: none;
  padding: calc(var(--cell) / 4) calc(var(--cell) * 7 / 12) calc(var(--cell) / 3);
  border: 1px solid var(--ink);
  background: var(--label);
  color: var(--ink);
  text-decoration: none;
}

.cover .school-label {
  color: var(--ink);
}

.cover .school-label:focus-visible {
  outline-color: var(--on-cover);
}

.label-kind,
.label-name,
.label-subtitle {
  display: block;
}

.label-kind,
.label-subtitle {
  color: var(--pencil);
  font-size: var(--size-tiny);
}

.label-kind {
  border-bottom: 1px solid var(--grid);
  line-height: 1.3333;
}

.label-name {
  border-bottom: 1px solid var(--grid);
  font-family: var(--font-hand);
  font-size: 1.53rem;
  font-weight: 700;
  line-height: 1.3077;
}

.label-subtitle {
  line-height: 1.5;
}

/* The language switch on top; the alphabet and accessibility links under it. */
.cover-tools {
  display: grid;
  justify-items: end;
  align-items: center;
  gap: calc(var(--cell) / 6) calc(var(--cell) / 2);
  margin-left: auto;
}

.cover .switch ul {
  flex-wrap: nowrap;
}

/* 44px squares: the language switch is the target most often hit on a phone. */
.switch a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: var(--touch-target);
  height: var(--touch-target);
  text-decoration: none;
}

.switch a[aria-current="page"] {
  background: var(--label);
  color: var(--ink);
  font-weight: 700;
}

.alphabet-switch,
.a11y-toggle {
  min-height: var(--cell);
  font-size: var(--size-small);
  line-height: 1.5385;
  text-align: right;
}

.a11y-toggle {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--on-cover);
  font-family: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  cursor: pointer;
}

.main-menu {
  flex-basis: 100%;
}

.main-menu ul {
  column-gap: calc(var(--cell) / 2);
  font-size: var(--size-menu);
}

.main-menu a {
  display: inline-block;
  line-height: var(--touch-target);
}

/* Russian menu words are longer; one pixel less keeps the menu on two lines at 360px. */
html:lang(ru) .main-menu ul {
  font-size: var(--size-note);
}

.main-menu a[aria-current="page"] {
  font-weight: 700;
}

@media (min-width: 960px) {
  .cover-bar {
    flex-wrap: nowrap;
    align-items: center;
    column-gap: calc(var(--cell) * 4 / 3);
    padding: calc(var(--cell) * 2 / 3) var(--cell);
  }

  .label-name {
    font-size: 1.647rem;
    line-height: 1.2857;
  }

  .main-menu {
    flex: 1 1 auto;
    order: 1;
  }

  .cover-tools {
    grid-template-columns: repeat(2, auto);
    order: 2;
  }

  .cover-tools > .switch {
    grid-column: 1 / -1;
  }

  .main-menu ul {
    column-gap: calc(var(--cell) * 5 / 6);
    font-size: 1rem;
  }
}

/* Accessibility panel: a plain index card under the cover. */
.a11y-panel {
  padding: calc(var(--cell) / 2) var(--cell) var(--cell);
  border-bottom: var(--rule-width) solid var(--ink);
  background: var(--label);
}

.a11y-panel-title {
  margin-bottom: calc(var(--cell) / 2);
}

.a11y-panel fieldset {
  display: flex;
  flex-wrap: wrap;
  gap: calc(var(--cell) / 4) var(--cell);
  margin: 0 0 calc(var(--cell) / 2);
  padding: calc(var(--cell) / 4) calc(var(--cell) / 2) calc(var(--cell) / 2);
  border: 1px solid var(--grid);
}

.a11y-panel legend {
  padding: 0 calc(var(--cell) / 4);
  font-weight: 700;
}

.a11y-panel label {
  display: inline-flex;
  align-items: center;
  gap: calc(var(--cell) / 4);
  min-height: var(--cell);
}

.a11y-panel input {
  width: calc(var(--cell) * 0.75);
  height: calc(var(--cell) * 0.75);
  margin: 0;
  accent-color: var(--ink);
}

.a11y-actions {
  display: flex;
  flex-wrap: wrap;
  gap: calc(var(--cell) / 2);
  margin: 0;
}

.a11y-actions button {
  min-height: var(--cell);
  padding: 0 calc(var(--cell) / 2);
  border: 1px solid var(--ink);
  background: var(--label);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

/* Paper: square grid drawn on the cell, red margin rule running the full height. */
.paper {
  position: relative;
  flex: 1;
  background-color: var(--paper);
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
}

.paper::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--margin-width);
  width: var(--rule-width);
  background: var(--red-pen);
}

html[data-a11y-theme="contrast"] .paper {
  background-image: none;
}

.content {
  max-width: 1240px;
  padding: var(--cell) var(--cell) calc(var(--cell) * 2) var(--content-inset);
}

/* One line of the exercise book: its time is written in the margin, its text on the page. */
.ruled-row {
  display: grid;
  grid-template-columns: var(--margin-width) minmax(0, 1fr);
  column-gap: calc(var(--rule-width) + var(--cell) / 2);
  margin-left: calc(-1 * var(--content-inset));
}

.ruled-body {
  grid-column: 2;
  min-width: 0;
}

.margin-note {
  grid-column: 1;
  margin: 0;
  padding: calc(var(--cell) / 2) calc(var(--cell) / 3) 0 0;
  font-family: var(--font-hand);
  font-size: var(--size-note);
  text-align: right;
  overflow-wrap: normal;
}

/* What only a teacher would write: days off, changes to the timetable. */
.is-red-pen {
  color: var(--red-pen);
}

/* "3-dars", "1-smena", "26-noyabr": a number and its word stay on one line. */
.nowrap {
  white-space: nowrap;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.content:focus {
  outline: none;
}

.page-heading {
  margin-bottom: var(--cell);
}

/* Forms: a white index card with square corners, so fields stay readable over the grid. */
.card {
  max-width: calc(var(--cell) * 18);
  padding: var(--cell);
  border: 1px solid var(--ink);
  background: var(--label);
}

.field {
  display: flex;
  flex-direction: column;
  gap: calc(var(--cell) / 4);
}

.field label {
  font-weight: 700;
}

.field input {
  min-height: calc(var(--cell) * 1.5);
  padding: 0 calc(var(--cell) / 4);
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--label);
  color: var(--ink);
  font: inherit;
}

.button,
.logout-form button {
  min-height: calc(var(--cell) * 1.5);
  padding: 0 var(--cell);
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--ink);
  color: var(--label);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.logout-form {
  margin: 0;
}

.logout-form button {
  min-height: var(--cell);
  border-color: var(--on-cover);
  background: transparent;
  color: var(--on-cover);
  font-weight: 400;
}

/* A teacher's red-pen remark next to the form. */
.form-error {
  color: var(--red-pen);
  font-weight: 700;
}

.footer {
  padding: var(--cell);
}

.footer p {
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
