/* Public-page UX and accessibility refinements. Kept separate so protected
   pages do not need a cache-buster or markup change. */
:root {
  --brown-soft: #68462e;
  --gold-dark: #6b4811;
  --focus-ring: #6b4811;
  --home-card-bg: rgba(255, 253, 248, 0.96);
  --home-card-border: #dccaa5;
  --home-card-radius: 14px;
  --home-card-shadow: 0 8px 18px rgba(91, 58, 36, 0.1);
  --home-card-shadow-hover: 0 15px 28px rgba(91, 58, 36, 0.17);
  --home-card-hover-border: #8a5e18;
  --home-card-ease: cubic-bezier(0.2, 0.75, 0.25, 1);
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

/* The public header upgrades its mobile menu from a hidden checkbox to a
   semantic button. These rules keep the existing visual treatment intact. */
.nav-burger {
  align-items: center;
  justify-content: center;
  font: inherit;
}

.nav-burger[aria-expanded="true"] {
  background: var(--beige);
  box-shadow: 0 0 0 2px rgba(107, 72, 17, 0.18);
}

@media (max-width: 720px) {
  .nav-links.nav-open {
    display: flex;
  }

  .nav-burger {
    min-width: 44px;
    min-height: 44px;
  }
}

/* Homepage starting routes */
.start-hub {
  margin: 28px 0 6px;
}

.start-hub .section-title {
  margin-top: 0;
}

.start-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.start-card {
  --card-accent: #6b4811;
  --card-accent-soft: #f6ecd2;
  display: flex;
  min-height: 318px;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--home-card-border);
  border-radius: var(--home-card-radius);
  background: var(--home-card-bg);
  box-shadow: var(--home-card-shadow);
  color: var(--ink);
  padding: 0;
  text-decoration: none;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.start-card-visual {
  position: relative;
  display: grid;
  width: 100%;
  height: 124px;
  flex: none;
  place-items: center;
  overflow: hidden;
  border-bottom: 1px solid rgba(91, 58, 36, 0.12);
}

.start-card-visual::after {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(91, 58, 36, 0.13) 1px, transparent 1.5px);
  background-size: 15px 15px;
  content: "";
  opacity: 0.18;
  pointer-events: none;
}

.start-card-pathways {
  --card-accent: #486c52;
  --card-accent-soft: #e3ede1;
}

.start-card-pathways .start-card-visual {
  background: #edf3e9;
}

.start-card-study {
  --card-accent: #6b4811;
  --card-accent-soft: #f6ecd2;
}

.start-card-study .start-card-visual {
  background: #fbf1d8;
}

.start-card-jupas {
  --card-accent: #7a3517;
  --card-accent-soft: #f1ddd5;
}

.start-card-jupas .start-card-visual {
  background: #f7e9e1;
}

.start-card-art {
  position: relative;
  z-index: 1;
  width: min(92%, 250px);
  height: 116px;
  filter: drop-shadow(0 5px 6px rgba(91, 58, 36, 0.12));
  transition: transform 220ms ease;
}

.start-card-copy {
  display: flex;
  width: 100%;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
  padding: 18px 20px 20px;
}

.start-card-eyebrow {
  color: var(--card-accent);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.start-card-title {
  color: var(--brown);
  font-family: var(--font-display);
  font-size: 1.22rem;
  font-weight: 800;
  line-height: 1.25;
}

.start-card-desc {
  color: #4d3728;
  font-size: 0.92rem;
  line-height: 1.55;
}

.start-card-link {
  display: inline-flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--card-accent);
  font-size: 0.9rem;
  font-weight: 800;
  margin-top: auto;
}

.start-card-link::after {
  display: inline-grid;
  width: 30px;
  height: 30px;
  flex: none;
  place-items: center;
  border-radius: 50%;
  background: var(--card-accent-soft);
  content: "\2192";
  font-size: 1.05em;
  transition: transform 180ms ease;
}

.start-card.is-gated {
  background: #fffaf2;
}

.start-card.is-gated .start-card-link::before {
  content: "🔒 ";
}

/* Homepage tool cards */
#tools .tools-grouptitle {
  margin: 28px 0 13px;
  color: var(--brown);
  font-size: 1.08rem;
  letter-spacing: 0;
  text-transform: none;
}

#tools .tools-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

#tools .tool-card {
  --tool-accent: #6b4811;
  --tool-soft: #f6ecd2;
  position: relative;
  display: flex;
  min-height: 354px;
  height: 100%;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--home-card-border);
  border-radius: var(--home-card-radius);
  background: var(--home-card-bg);
  box-shadow: var(--home-card-shadow);
  color: var(--ink);
  padding: 0;
  text-decoration: none;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

#tools .tool-card::before {
  display: none;
}

#tools .tool-card[data-gated="true"] {
  border-left: 1px solid var(--home-card-border);
}

#tools .tool-card[data-tool="quiz"],
#tools .tool-card[data-tool="pathways"] {
  --tool-accent: #486c52;
  --tool-soft: #e3ede1;
}

#tools .tool-card[data-tool="pomodoro"],
#tools .tool-card[data-tool="studyplan"] {
  --tool-accent: #6b4811;
  --tool-soft: #f6ecd2;
}

#tools .tool-card[data-tool="dse"],
#tools .tool-card[data-tool="planner"] {
  --tool-accent: #8a4c31;
  --tool-soft: #f1ddd5;
}

#tools .tool-card[data-tool="streaming"],
#tools .tool-card[data-tool="jupaschoices"] {
  --tool-accent: #336e65;
  --tool-soft: #dcebe7;
}

#tools .tool-card[data-tool="jupas"] {
  --tool-accent: #68462e;
  --tool-soft: #eee2cf;
}

#tools .tool-card-top {
  position: relative;
  display: grid;
  width: 100%;
  height: 126px;
  flex: none;
  place-items: center;
  overflow: hidden;
  border-bottom: 1px solid rgba(91, 58, 36, 0.12);
  background: var(--tool-soft);
}

#tools .tool-card-top::after {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(91, 58, 36, 0.13) 1px, transparent 1.5px);
  background-size: 15px 15px;
  content: "";
  opacity: 0.18;
  pointer-events: none;
}

#tools .tool-ic {
  position: relative;
  z-index: 1;
  display: grid;
  width: 100%;
  height: 126px;
  place-items: center;
}

#tools .tool-ic svg {
  width: min(82%, 230px);
  height: 116px;
  filter: drop-shadow(0 5px 6px rgba(91, 58, 36, 0.12));
  transition: transform 220ms ease;
}

#tools .tool-tags {
  position: absolute;
  z-index: 2;
  top: 10px;
  right: 10px;
  display: flex;
  max-width: calc(100% - 20px);
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  margin: 0;
}

#tools .tool-aud,
#tools .tool-lock {
  border-radius: 6px;
  font-size: 0.7rem;
  line-height: 1.25;
  padding: 5px 8px;
}

#tools .tool-aud {
  border: 1px solid rgba(91, 58, 36, 0.13);
  background: rgba(255, 253, 248, 0.92);
  box-shadow: 0 2px 6px rgba(91, 58, 36, 0.08);
  color: var(--tool-accent);
}

#tools .tool-lock {
  border-color: #e3c27f;
  background: #fff3dd;
  color: #75470e;
}

#tools .tool-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 7px;
  padding: 17px 18px 0;
}

#tools .tool-name {
  color: var(--brown);
  font-size: 1.12rem;
  line-height: 1.3;
  text-wrap: balance;
}

#tools .tool-desc {
  color: #4d3728;
  font-size: 0.9rem;
  line-height: 1.55;
}

#tools .tool-card-foot {
  display: flex;
  width: auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px dotted #d8c38f;
  margin: 14px 18px 0;
  padding: 12px 0 16px;
}

#tools .tool-action {
  color: var(--tool-accent);
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.4;
}

#tools .tool-action.is-gated {
  color: #68462e;
  font-size: 0.75rem;
}

#tools .tool-arrow {
  display: grid;
  width: 30px;
  height: 30px;
  flex: none;
  place-items: center;
  border-radius: 50%;
  background: var(--tool-soft);
  color: var(--tool-accent);
  font-weight: 800;
  transition: transform 180ms ease;
}

/* Homepage news cards, ready for the currently hidden news section. */
#news .grid {
  gap: 14px;
}

#news .card {
  --news-accent: #6b4811;
  position: relative;
  border: 1px solid var(--home-card-border);
  border-radius: var(--home-card-radius);
  background: var(--home-card-bg);
  box-shadow: var(--home-card-shadow);
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

#news .card[data-category="local"] { --news-accent: #486c52; }
#news .card[data-category="mainland"] { --news-accent: #8a4c31; }
#news .card[data-category="foreign"] { --news-accent: #6b4811; }
#news .card[data-category="career"] { --news-accent: #336e65; }

#news .card::before {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 18px;
  width: 46px;
  height: 4px;
  border-radius: 0 0 4px 4px;
  background: var(--news-accent);
  content: "";
}

#news .card::after {
  display: none;
}

#news .card:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

#news .card .thumb {
  aspect-ratio: 16 / 9;
  border-bottom: 1px solid rgba(91, 58, 36, 0.11);
}

#news .card .thumb.empty {
  background: #f4eddd;
}

#news .card .pad {
  gap: 9px;
  padding: 17px 18px 20px;
}

#news .card-flags {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#news .tag,
#news .pin {
  border-radius: 6px;
}

#news .pin {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #e4ca89;
  background: #fff4d8;
  padding: 4px 8px;
}

#news .pin::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--news-accent);
  content: "";
}

#news .card h3 {
  font-weight: 800;
  line-height: 1.35;
  text-wrap: balance;
}

#news .card .excerpt {
  color: #4d3728;
  line-height: 1.55;
}

#news .card .readmore {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--news-accent);
}

#news .card .readmore::after {
  display: grid;
  width: 30px;
  height: 30px;
  flex: none;
  place-items: center;
  border-radius: 50%;
  background: #f3ead8;
  content: "\2192";
  transition: transform 180ms ease;
}

#news .empty-state {
  border: 1px dashed var(--home-card-border);
  border-radius: var(--home-card-radius);
  background: rgba(255, 253, 248, 0.72);
}

/* One interaction contract for every homepage card family. */
.start-card,
#tools .tool-card,
#news .card {
  transition:
    transform 200ms var(--home-card-ease),
    box-shadow 200ms var(--home-card-ease),
    border-color 200ms var(--home-card-ease);
}

.start-card:hover,
#tools .tool-card:hover,
#news .card:hover {
  z-index: 1;
  border-color: var(--home-card-hover-border);
  box-shadow: var(--home-card-shadow-hover);
  text-decoration: none;
  transform: translateY(-4px);
}

.start-card:active,
#tools .tool-card:active,
#news .card:active {
  transform: translateY(-1px);
}

.start-card:focus-visible,
#tools .tool-card:focus-visible,
#news .card:focus-visible {
  border-color: var(--home-card-hover-border);
  box-shadow: var(--home-card-shadow-hover);
  transform: none;
}

.start-card-art,
#tools .tool-ic svg,
#news .card .thumb img {
  transition: transform 220ms var(--home-card-ease);
}

.start-card:hover .start-card-art,
#tools .tool-card:hover .tool-ic svg,
#news .card:hover .thumb img {
  transform: translateY(-2px) scale(1.025);
}

.start-card-link::after,
#tools .tool-arrow,
#news .card .readmore::after {
  transition: transform 200ms var(--home-card-ease);
}

.start-card:hover .start-card-link::after,
#tools .tool-card:hover .tool-arrow,
#news .card:hover .readmore::after {
  transform: translateX(3px);
}

@media (max-width: 920px) {
  #tools .tools-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .start-hub .section-title {
    font-size: 1.55rem;
    line-height: 1.3;
    text-wrap: balance;
  }

  .start-hub .section-title::after {
    display: none;
  }

  .start-grid {
    grid-template-columns: 1fr;
  }

  .start-card {
    min-height: 0;
  }

  .start-card-visual {
    height: 116px;
  }

  .start-card-art {
    height: 110px;
  }

  #tools .tool-card-top,
  #tools .tool-ic {
    height: 118px;
  }

  #tools .tool-ic svg {
    height: 110px;
  }
}

@media (max-width: 620px) {
  #tools .tools-grid {
    grid-template-columns: 1fr;
  }

  #tools .tool-card {
    min-height: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .start-card {
    transition: none;
  }

  .start-card:hover,
  .start-card:active,
  #tools .tool-card:hover,
  #tools .tool-card:active,
  #news .card:hover,
  #news .card:active {
    transform: none;
  }

  .start-card-art,
  .start-card-link::after,
  #tools .tool-ic svg,
  #tools .tool-arrow,
  #news .card .readmore::after {
    transition: none;
  }

  .start-card:hover .start-card-art,
  .start-card:hover .start-card-link::after,
  #tools .tool-card:hover .tool-ic svg,
  #tools .tool-card:hover .tool-arrow,
  #news .card:hover .readmore::after {
    transform: none;
  }
}
