/*
 * liquid-crystal.css – The shared "Liquid Crystal" style for every GuruNest page.
 * Used by: every page in frontend/ (login, activate, register now; main screen later).
 * Who sees it: everyone.
 * How to edit: change colours, blur, radii, fonts and speed ONLY in the TOKENS block.
 *               Everything below reads from those tokens, so one change updates every page.
 */

/* This loads the heading fonts (Cormorant Garamond and the Noto Serif Sinhala and Tamil faces) from Google Fonts. */
@import url("https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600;700&family=Noto+Serif+Sinhala:wght@500;600&family=Noto+Serif+Tamil:wght@500;600&display=swap");

/* This is the TOKENS block: every colour, blur, radius, font and speed lives here. */
:root {
  /* Fonts. Headings use a serif with warmth; body text uses a clean sans.
     Sinhala and Tamil get their own faces so all three languages look equally good.
     Web fonts (Fraunces, Inter, Noto) are not loaded yet; they wait for the owner's OK. */
  /* Headings use Cormorant Garamond, with Noto Serif Sinhala and Tamil as backups.
     Body text uses the phone or PC's own clean font. Sinhala and Tamil use Noto Sans Sinhala and Noto Sans Tamil.
     To change the heading font, edit --font-display here. */
  --font-display: "Cormorant Garamond", "Noto Serif Sinhala", "Noto Serif Tamil", Georgia, "Times New Roman", serif;
  --font-text: "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-sinhala: "Noto Sans Sinhala", "Nirmala UI", "Segoe UI", sans-serif;
  --font-tamil: "Noto Sans Tamil", "Nirmala UI", "Latha", "Segoe UI", sans-serif;

  /* Light theme: white crystal glass on a soft blue-white background, with light blue glows (the Itachi look).
     Light blue is for buttons and highlights; links use a deeper blue so they stay easy to read on white. */
  --colour-bg: #eef6ff;
  --colour-blob-a: rgba(120, 190, 255, 0.45);
  --colour-blob-b: rgba(170, 215, 255, 0.40);
  --colour-blob-c: rgba(255, 255, 255, 0.85);
  --colour-panel: rgba(255, 255, 255, 0.72);
  --colour-panel-solid: #ffffff;
  --colour-edge: rgba(255, 255, 255, 0.95);
  --colour-glow: rgba(120, 190, 255, 0.20);
  --colour-text: #13293d;
  --colour-text-soft: rgba(19, 41, 61, 0.72);
  --colour-field: rgba(255, 255, 255, 0.90);
  --colour-field-border: rgba(31, 95, 150, 0.28);
  --colour-primary: #4aa3e8;
  --colour-primary-text: #ffffff;
  --colour-accent: #7cc4ff;
  /* The dark text put on top of an accent-coloured badge. */
  --colour-on-accent: #0d2233;
  --colour-link: #1f6fb2;
  /* Main buttons: white crystal fading into light blue, with deep blue text. */
  --colour-button-bg: linear-gradient(135deg, #ffffff, #cfe8ff);
  --colour-button-text: #1f5f96;
  --colour-button-edge: rgba(31, 95, 150, 0.35);
  --colour-error: #c62828;
  --colour-success: #2e7d32;
  /* The soft shadow under every glass panel and button. */
  --colour-shadow: rgba(40, 90, 140, 0.16);

  /* Glass: the blur, the edge and the rounded corners of the Itachi cards. */
  --blur-panel: 22px;
  --saturate-panel: 140%;
  --radius-panel: 24px;
  --radius-control: 12px;
  --motion-short: 200ms;
  --motion-blob: 40s;
  /* Tells the browser to draw its own controls (dropdowns, date boxes) in light colours. */
  color-scheme: light;
}

/* Dark theme: follows the phone or PC setting unless the user chooses light.
   It is light red crystal with light blue glows. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --colour-bg: #1d0f15;
    --colour-blob-a: rgba(255, 130, 140, 0.42);
    --colour-blob-b: rgba(120, 190, 255, 0.40);
    --colour-blob-c: rgba(255, 170, 180, 0.22);
    --colour-panel: rgba(255, 255, 255, 0.10);
    --colour-panel-solid: #2c1a21;
    --colour-edge: rgba(255, 255, 255, 0.24);
    --colour-glow: rgba(120, 190, 255, 0.10);
    --colour-text: rgba(255, 255, 255, 0.94);
    --colour-text-soft: rgba(255, 255, 255, 0.68);
    --colour-field: rgba(255, 255, 255, 0.10);
    --colour-field-border: rgba(150, 200, 255, 0.40);
    --colour-primary: #ff8c96;
    --colour-primary-text: #2a0c12;
    --colour-accent: #9fd3ff;
    --colour-link: #ffa3aa;
    --colour-button-bg: linear-gradient(135deg, #ffa0a8, #ff7a86);
    --colour-button-text: #2a0c12;
    --colour-button-edge: transparent;
    --colour-error: #ff8a80;
    --colour-success: #9be7b0;
    --colour-shadow: rgba(0, 0, 0, 0.40);
  }
}

/* Dark theme chosen by the user on purpose (the Theme choice in the header). */
:root[data-theme="dark"] {
  color-scheme: dark;
  --colour-bg: #1d0f15;
  --colour-blob-a: rgba(255, 130, 140, 0.42);
  --colour-blob-b: rgba(120, 190, 255, 0.40);
  --colour-blob-c: rgba(255, 170, 180, 0.22);
  --colour-panel: rgba(255, 255, 255, 0.10);
  --colour-panel-solid: #2c1a21;
  --colour-edge: rgba(255, 255, 255, 0.24);
  --colour-glow: rgba(120, 190, 255, 0.10);
  --colour-text: rgba(255, 255, 255, 0.94);
  --colour-text-soft: rgba(255, 255, 255, 0.68);
  --colour-field: rgba(255, 255, 255, 0.10);
  --colour-field-border: rgba(150, 200, 255, 0.40);
  --colour-primary: #ff8c96;
  --colour-primary-text: #2a0c12;
  --colour-accent: #9fd3ff;
  --colour-link: #ffa3aa;
  --colour-button-bg: linear-gradient(135deg, #ffa0a8, #ff7a86);
  --colour-button-text: #2a0c12;
  --colour-button-edge: transparent;
  --colour-error: #ff8a80;
  --colour-success: #9be7b0;
  --colour-shadow: rgba(0, 0, 0, 0.40);
}
/* Every box counts its padding and border inside its width, so a 100%-wide box never spills into the next button. */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* This is the base style of the whole page (font, colour and the background). */
html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--colour-bg);
  color: var(--colour-text);
  font-family: var(--font-text);
  line-height: 1.5;
  overflow-x: hidden;
}

/* This is the slow-moving coloured background behind the glass. It drifts very slowly. */
body::before {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: -1;
  background:
    radial-gradient(circle at 20% 30%, var(--colour-blob-a) 0, transparent 40%),
    radial-gradient(circle at 80% 20%, var(--colour-blob-b) 0, transparent 38%),
    radial-gradient(circle at 60% 85%, var(--colour-blob-c) 0, transparent 42%);
  animation: blob-drift var(--motion-blob) ease-in-out infinite alternate;
}

/* This is the slow movement used by the background blobs. */
@keyframes blob-drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(3%, -2%, 0) scale(1.05); }
}

/* This makes the "hidden" attribute always hide an element, even when its own style asks for a display type. */
[hidden] {
  display: none !important;
}

/* This is the wrapper around a password box, so the eye button can sit inside its right edge. */
.password-field {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
}

/* This is the space on the right of a password box, so the typed text does not run under the eye. */
.password-field .field-input {
  box-sizing: border-box;
  padding-right: 3rem;
}

/* This is the eye button that shows or hides the password. */
.password-eye {
  position: absolute;
  top: 50%;
  right: 0.5rem;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--colour-text-soft);
  cursor: pointer;
  transition: color var(--motion-short), background var(--motion-short);
}

/* This is how the eye button looks when the mouse is over it or it has keyboard focus. */
.password-eye:hover,
.password-eye:focus-visible {
  color: var(--colour-link);
  background: var(--colour-field);
  outline: none;
}

/* This is the photo of a student or a staff member on their page. It keeps its shape, and crops to a square. */
.person-photo {
  display: block;
  width: 140px;
  height: 140px;
  margin: 0 0 10px;
  object-fit: cover;
  border-radius: var(--radius-control);
  border: 1px solid var(--colour-field-border);
}

/* This is the list of files under a notice. The files sit side by side, and wrap onto a new line when there is no room. */
.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}

/* This is the style for a frosted glass panel. Important panels are the ones with the strongest glow. */
.glass-panel {
  background: var(--colour-panel);
  -webkit-backdrop-filter: blur(var(--blur-panel)) saturate(var(--saturate-panel));
  backdrop-filter: blur(var(--blur-panel)) saturate(var(--saturate-panel));
  border: 1px solid var(--colour-edge);
  border-radius: var(--radius-panel);
  /* The first inset shadow is the bright 1px edge on the top and left. The second is the inner glow.
     The outer shadow lifts the panel off the background, as the Itachi cards float. */
  box-shadow:
    inset 1px 1px 0 var(--colour-edge),
    inset 0 0 24px var(--colour-glow),
    0 10px 30px var(--colour-shadow);
  padding: 28px;
  /* Every panel rises gently into place when the page opens (see the animations block below). */
  animation: glass-rise 420ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

/* This is the stagger: each later panel on a page starts a little after the one before it. */
.glass-panel:nth-of-type(2) { animation-delay: 60ms; }
.glass-panel:nth-of-type(3) { animation-delay: 120ms; }
.glass-panel:nth-of-type(4) { animation-delay: 180ms; }
.glass-panel:nth-of-type(5) { animation-delay: 240ms; }

/* This is the entrance of a panel: it fades in and rises 12px. No bounce. */
@keyframes glass-rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* This is the entrance of the page title and the header: a quick fade. */
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* This is the header and title fade in at the start of each page. */
.site-header,
.page-title {
  animation: fade-in 500ms ease-out both;
}

/* This is the accent line under a title: it grows from the left. */
.accent-rule {
  transform-origin: left center;
  animation: rule-grow 600ms ease-out 150ms both;
}

@keyframes rule-grow {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

/* This is the login and sign-up forms: each field and button appears one after another, so the form feels alive. */
.auth-layout .glass-panel form > * {
  animation: fade-in 400ms ease-out both;
}
.auth-layout .glass-panel form > *:nth-child(2) { animation-delay: 70ms; }
.auth-layout .glass-panel form > *:nth-child(3) { animation-delay: 140ms; }
.auth-layout .glass-panel form > *:nth-child(4) { animation-delay: 210ms; }
.auth-layout .glass-panel form > *:nth-child(5) { animation-delay: 280ms; }
.auth-layout .glass-panel form > *:nth-child(6) { animation-delay: 350ms; }

/* This is a message box (error or success): it fades in when it appears. */
.form-message {
  animation: fade-in 250ms ease-out both;
}

/* This is a list of notices or students: each item fades in, one after another (the first eight). */
.notice-list > li,
.student-list > li {
  animation: fade-in 350ms ease-out both;
}
.notice-list > li:nth-child(2),
.student-list > li:nth-child(2) { animation-delay: 40ms; }
.notice-list > li:nth-child(3),
.student-list > li:nth-child(3) { animation-delay: 80ms; }
.notice-list > li:nth-child(4),
.student-list > li:nth-child(4) { animation-delay: 120ms; }
.notice-list > li:nth-child(5),
.student-list > li:nth-child(5) { animation-delay: 160ms; }
.notice-list > li:nth-child(6),
.student-list > li:nth-child(6) { animation-delay: 200ms; }
.notice-list > li:nth-child(7),
.student-list > li:nth-child(7) { animation-delay: 240ms; }
.notice-list > li:nth-child(8),
.student-list > li:nth-child(8) { animation-delay: 280ms; }

/* This is the press movement on the small tab-like buttons, so every tap gives a response. */
button:not(:disabled):active {
  transform: scale(0.98);
}

/* This is the header of the page: the school app name and the language and Lite controls. */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  max-width: 1100px;
  margin: 0 auto;
}

/* This is the app name in the header. */
.brand-name {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin: 0;
  letter-spacing: 0.2px;
}

/* This is the short tagline under the app name. */
.brand-tagline {
  margin: 0;
  font-size: 0.9rem;
  color: var(--colour-text-soft);
}

/* This is the group of controls on the right of the header (language and Lite mode). */
.header-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

/* This is the style for the language dropdown. */
.language-select {
  min-height: 44px;
  padding: 6px 10px;
  border-radius: var(--radius-control);
  border: 1px solid var(--colour-field-border);
  background: var(--colour-field);
  color: var(--colour-text);
  font: inherit;
}

/* This is the Lite mode tick box with its label. */
.lite-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--colour-text-soft);
  min-height: 44px;
}

/* This is the main part of every page. It keeps a 16px gutter on phones. */
.page-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 8px 16px 40px;
}

/* This is the big page title. It is the most important item on the page. It uses the dark gold, like the U&We titles. */
.page-title {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: 0.01em;
  color: var(--colour-link);
  margin: 0 0 12px;
}

/* This is the short line under a title. */
.page-intro {
  color: var(--colour-text-soft);
  margin: 0 0 20px;
  max-width: 34ch;
}

/* This is the thin gold line under a title. The accent colour is used only here, sparingly. */
.accent-rule {
  width: 56px;
  height: 3px;
  border-radius: 2px;
  background: var(--colour-accent);
  margin: 12px 0 18px;
}

/* This is the small heading that starts each part of a form. */
.form-section-title {
  font-size: 1.05rem;
  margin: 0 0 12px;
  color: var(--colour-link);
}

/* This is the label above every input. */
.field-label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--colour-text-soft);
  margin-bottom: 6px;
}

/* This is the style for every text box, email box, password box and dropdown. */
.field-input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: var(--radius-control);
  border: 1px solid var(--colour-field-border);
  background: var(--colour-field);
  color: var(--colour-text);
  font: inherit;
  transition: border-color var(--motion-short) ease, box-shadow var(--motion-short) ease;
}

/* This is the highlight of a text box when someone is typing in it: a red edge and a soft glow. */
.field-input:focus-visible {
  outline: none;
  border-color: var(--colour-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--colour-primary) 30%, transparent);
}

/* This is the small grey hint under a field. */
.field-hint {
  display: block;
  font-size: 0.85rem;
  color: var(--colour-text-soft);
  margin-top: 4px;
}

/* This is the main button on each form. */
.button-primary {
  min-height: 48px;
  padding: 12px 22px;
  border: 1px solid var(--colour-button-edge);
  border-radius: 999px;
  /* Dark theme: the red gradient from the Itachi buttons. Light theme: white crystal with an amber edge. */
  background: var(--colour-button-bg);
  color: var(--colour-button-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 18px var(--colour-shadow);
  transition: transform var(--motion-short) ease, box-shadow var(--motion-short) ease, filter var(--motion-short) ease, opacity var(--motion-short) ease;
}

/* This is the button when the mouse is over it: it lifts 1px and the glow grows. */
.button-primary:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: 0 10px 24px var(--colour-shadow);
}

/* This is the button while it is pressed: it sinks slightly, so the touch feels solid. */
.button-primary:active {
  transform: scale(0.98);
}

/* This is the quiet glass button used for secondary actions (for example "Show summary" or "Switch off"). */
.button-quiet {
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--colour-edge);
  border-radius: 999px;
  background: var(--colour-field);
  color: var(--colour-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transition: transform var(--motion-short) ease, background var(--motion-short) ease;
}

/* This is the quiet button when the mouse is over it, and when it is pressed. */
.button-quiet:hover {
  background: var(--colour-panel-solid);
}

.button-quiet:active {
  transform: scale(0.98);
}

.button-quiet:focus-visible {
  outline: 3px solid var(--colour-accent);
  outline-offset: 2px;
}

/* This is the button when it cannot be pressed (while the form is being sent). */
.button-primary:disabled {
  opacity: 0.6;
  cursor: progress;
}

/* This is the keyboard focus ring on every button and link. */
.button-primary:focus-visible,
.text-link:focus-visible {
  outline: 3px solid var(--colour-accent);
  outline-offset: 2px;
}

/* This is the style for a link inside the text. */
.text-link {
  color: var(--colour-link);
  font-weight: 600;
}

/* This is the box that shows an error or a success message. */
.form-message {
  padding: 12px 14px;
  border-radius: var(--radius-control);
  margin: 0 0 16px;
  border-left: 4px solid transparent;
  background: var(--colour-field);
}

/* This is the style for an error message. */
.form-message-error {
  color: var(--colour-error);
  border-left-color: var(--colour-error);
}

/* This is the style for a success message. */
.form-message-success {
  color: var(--colour-success);
  border-left-color: var(--colour-success);
}

/* This is the two-column layout used by the login and activate pages (one column on phones). */
.auth-layout {
  display: grid;
  gap: 24px;
  grid-template-columns: 1fr;
  align-items: start;
}

/* This is the wide-screen layout: the page title takes more room than the form panel. */
@media (min-width: 860px) {
  .auth-layout {
    grid-template-columns: 1.15fr 0.85fr;
    align-items: center;
  }
}

/* This is the grid that places form fields in one or two columns. */
.form-grid {
  display: grid;
  gap: 16px;
}

/* This is the two-column version of the grid on wider screens. */
@media (min-width: 640px) {
  .form-grid.two-columns {
    grid-template-columns: 1fr 1fr;
  }
}

/* This is for a field that should take the full width of the row. */
.full-width {
  grid-column: 1 / -1;
}

/* This is for a label that screen readers need but sighted users do not see (the dropdown has its own look). */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* This is the Sinhala text setting: the Sinhala font is used for all text on the page. */
html[lang="si"] body,
html[lang="si"] .page-title,
html[lang="si"] .brand-name {
  font-family: var(--font-sinhala);
}

/* This is the Tamil text setting: the Tamil font is used for all text on the page. */
html[lang="ta"] body,
html[lang="ta"] .page-title,
html[lang="ta"] .brand-name {
  font-family: var(--font-tamil);
}

/* This is the Lite mode setting for budget phones: solid panels and no blur. */
html[data-lite="on"] body::before {
  animation: none;
}

/* This is the solid panel used in Lite mode (no blur, which is slow on budget phones). */
html[data-lite="on"] .glass-panel {
  background: var(--colour-panel-solid);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

/* This is the status line at the top of the page: how many changes wait to be sent on this device. */
.sync-status {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 10px 16px;
  margin: 0 auto;
  max-width: 1100px;
  background: var(--colour-panel-solid);
  border-bottom: 3px solid var(--colour-accent);
  font-size: 0.95rem;
}

/* This is a refused change: shown in the error colour, with its reason. */
.sync-rejected {
  color: var(--colour-error);
  font-weight: 600;
}

/* This is the bottom navigation bar: a floating glass bar with the main pages, like the Itachi downloader's tab bar. */
.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  justify-content: space-around;
  gap: 4px;
  width: min(560px, calc(100% - 16px));
  padding: 6px;
  border-radius: 30px;
  background: var(--colour-panel);
  -webkit-backdrop-filter: blur(var(--blur-panel)) saturate(var(--saturate-panel));
  backdrop-filter: blur(var(--blur-panel)) saturate(var(--saturate-panel));
  border: 1px solid var(--colour-edge);
  box-shadow: 0 10px 30px var(--colour-shadow);
}

/* This is one item on the bottom bar: an icon with its name under it. */
.bottom-nav a {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
  padding: 6px 2px;
  border-radius: 20px;
  color: var(--colour-text-soft);
  text-decoration: none;
  font-size: 0.66rem;
  white-space: nowrap;
  font-weight: 600;
  transition: background var(--motion-short) ease, color var(--motion-short) ease, transform var(--motion-short) ease;
}

/* This is the icon of a bottom bar item. */
.bottom-nav svg {
  width: 22px;
  height: 22px;
}

/* This is the item of the page on screen: it is red and has a soft red background. */
.bottom-nav a[aria-current="page"] {
  color: var(--colour-link);
  background: color-mix(in srgb, var(--colour-primary) 16%, transparent);
}

/* This is the press movement on a bottom bar item. */
.bottom-nav a:active {
  transform: scale(0.96);
}

.bottom-nav a:focus-visible {
  outline: 3px solid var(--colour-accent);
  outline-offset: 2px;
}

/* This leaves room under the page content, so the last items are not hidden behind the bottom bar. */
body.has-bottom-nav {
  padding-bottom: 110px;
}

/* This is the Lite mode bottom bar: a solid bar with no blur. */
html[data-lite="on"] .bottom-nav {
  background: var(--colour-panel-solid);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

/* Dropdown lists: every choice gets a solid panel colour and the normal text colour, so no choice is invisible
   (the browser's popup list otherwise showed light text on a white background in dark mode). */
select,
select option,
select optgroup {
  background-color: var(--colour-panel-solid);
  color: var(--colour-text);
}

/* This is the setting for people who asked their device to reduce motion. */
@media (prefers-reduced-motion: reduce) {
  body::before {
    animation: none;
  }

  * {
    transition-duration: 0ms !important;
    animation: none !important;
  }
}

/* This is the Lite mode setting: no entrance animations, no press movement (budget phones keep the page still). */
html[data-lite="on"] * {
  animation: none !important;
  transition: none !important;
}
