/* hub/hub.css: the home page (spec: specs/hub.md). Loads after shared/ui/page.css.
 * Theme variables only. On computers every tool is a square card of the same
 * size; hub.js shrinks the names until every word fits (--name-size) and makes
 * all cards as tall as the tallest one when a description needs more than a
 * square (--card-h). The flagships (li.featured: Choordination, Chordigits) are
 * first and bigger: two columns by two rows each. On phones the flagship is a full-width card
 * and the other tools are one grouped list (rows split by thin lines), so names
 * and descriptions stay readable. .beta-badge: a "Beta" tag on a card.
 */
/* Language flag, top right, and its little menu. */
.lang-pick { position: relative; }
.flag-btn .flag { width: 26px; height: 18px; }
.flag { display: block; border-radius: 3px; box-shadow: 0 0 0 1px color-mix(in srgb, var(--color-text) 25%, transparent); }
.lang-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 168px; padding: 6px;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--bg-select); border: 1px solid var(--border-panel); border-radius: var(--radius-control);
  box-shadow: 0 14px 34px -12px rgba(0, 0, 0, 0.5);
}
.lang-menu[hidden] { display: none; }
.lang-menu button {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 10px; cursor: pointer; text-align: left;
  border: 0; border-radius: calc(var(--radius-control) - 4px); background: transparent;
  color: var(--color-select-text); font-family: var(--font-main); font-size: 15px; font-weight: 600;
}
.lang-menu .flag { width: 24px; height: 16px; flex: none; }
.lang-menu button:hover, .lang-menu button[aria-checked="true"] { background: var(--color-select-hover); }
.lang-menu button:focus-visible { outline: 2px solid var(--color-right); outline-offset: -2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.hub-top { position: relative; }
.hub-top > .header-actions { position: absolute; top: 0; right: 0; }
.hub-hero { display: flex; flex-direction: column; align-items: flex-start; padding: var(--space-2) 0 var(--space-3); }
.hub-logo { width: 84px; height: auto; color: var(--color-right); }
body:is([data-theme="y2k"], [data-theme="retro"]) .hub-logo { color: var(--color-left); }
.hub-name {
  margin: var(--space-3) 0 0; font-family: var(--font-display); font-size: 40px; line-height: 1.02; font-weight: var(--title-weight);
  text-transform: var(--title-transform); letter-spacing: var(--title-spacing); color: var(--color-title); text-wrap: balance;
}
.hub-tagline { margin: var(--space-3) 0 0; max-width: 34em; font-size: 18px; line-height: 1.45; text-wrap: pretty; }
.hub-privacy { margin: var(--space-2) 0 0; max-width: 44em; font-size: 14px; line-height: 1.45; color: var(--color-text-inactive); text-wrap: pretty; }

.hub-main { display: flex; flex-direction: column; gap: var(--space-6); }
.hub-section-title { margin: 0 0 var(--space-3); font-size: 15px; font-weight: 600; line-height: 1.3; color: var(--color-text-inactive); }
.tool-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }
.tool-grid > li { display: flex; min-width: 0; }

.tool-card {
  /* min-width 0: otherwise min-height would widen the square past its column. */
  box-sizing: border-box; flex: 1; min-width: 0; min-height: max(170px, var(--card-h, 0px));
  display: flex; flex-direction: column; gap: var(--space-2); padding: 20px;
  background: var(--color-panel); border: var(--border-width) solid var(--border-panel); border-radius: var(--radius-panel);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  color: var(--color-text); text-decoration: none;
  -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none;
  transition: border-color 0.15s ease-out, transform 0.15s ease-out, background 0.15s ease-out, box-shadow 0.2s ease-out;
}
.tool-icon { width: 34px; height: 34px; flex: none; margin-bottom: var(--space-1); fill: none; stroke: var(--color-right); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tool-icon .fill { fill: var(--color-right); stroke: none; }
.tool-icon .dots { stroke-width: 3; }
.tool-name {
  font-family: var(--font-display); font-size: var(--name-size, 21px); font-weight: var(--title-weight); line-height: 1.12;
  text-transform: var(--title-transform); letter-spacing: var(--title-spacing); color: var(--color-title); overflow-wrap: normal; hyphens: none;
}
.tool-desc { font-size: 15px; line-height: 1.45; color: color-mix(in srgb, var(--color-text) 82%, transparent); text-wrap: pretty; }

/* The flagship: two columns by two rows, bigger drawing and name, accent border. */
.tool-grid > li.featured { grid-column: span 2; grid-row: span 2; }
.featured .tool-card { aspect-ratio: auto; min-height: 0; justify-content: flex-end; gap: var(--space-3); padding: 32px; border-color: var(--color-right); }
.featured .tool-icon { width: 64px; height: 64px; margin-bottom: auto; }
.featured .tool-name { font-size: calc(1.8 * var(--name-size, 21px)); line-height: 1; }
.featured .tool-desc { font-size: 18px; max-width: 24em; }
/* The flagship's two chord wheels, as in the tool (computers and tablets). */
.featured-art { position: absolute; top: 56px; right: 32px; width: min(46%, 260px); height: auto; pointer-events: none; }
.featured-art circle { fill: none; stroke-width: 22; }
.featured-art .wheel { stroke: color-mix(in srgb, var(--color-text) 14%, transparent); }
.featured-art .wheel-on.left { stroke: var(--color-left); }
.featured-art .wheel-on.right { stroke: var(--color-right); }
/* Chordigits: the wave of a chord (C major), as it draws across the tool's screen. */
.featured-art :is(.wave, .wave-glow) { fill: none; stroke: var(--color-right); stroke-linecap: round; stroke-linejoin: round; }
.featured-art .wave { stroke-width: 4; }
.featured-art .wave-glow { stroke-width: 12; opacity: 0.18; }

/* Name and description at the foot of each card, the drawing at the top. */
.tool-grid > li:not(.featured) .tool-icon { margin-bottom: auto; }
/* No hole after the last tool. Two flagships and seven tools: four columns put
   the seven in a row of 4 and one of 3, so the last card is wider; three columns
   fill exactly once the small cards may fill the gaps beside the flagships (dense). */
.tool-grid { grid-auto-flow: dense; }
/* Side by side, the flagships set their own height: room for the art above the name. */
@media (min-width: 601px) { .featured .tool-card { min-height: 340px; } }
@media (min-width: 861px) { section:first-of-type .tool-grid > li:last-child:nth-child(odd) { grid-column: span 2; } }
/* Planned tools: compact rows, lighter than the real ones. */
.tool-card.soon { min-height: 0; display: grid; grid-template-columns: 28px minmax(0, 1fr); column-gap: var(--space-3); row-gap: 2px; align-items: center; padding: 14px 16px; }
.tool-card.soon .tool-icon { grid-row: span 2; width: 26px; height: 26px; margin: 0; }
.tool-card.soon .tool-name { font-size: 17px; }
.tool-card.soon .tool-desc { font-size: 13px; line-height: 1.35; }

/* "Beta": a tool still being tried out. */
.tool-card { position: relative; }
.beta-badge {
  position: absolute; top: 14px; right: 14px;
  padding: 3px 10px; border: 1px solid var(--color-right); border-radius: 999px;
  font-size: 12px; font-weight: 700; line-height: 1.3; color: var(--color-right);
}

a.tool-card:active { transform: scale(0.98); }
@media (hover: hover) {
  a.tool-card:hover { border-color: var(--color-right); background: color-mix(in srgb, var(--color-right) 12%, var(--color-panel)); transform: translateY(-2px); box-shadow: 0 14px 28px -16px rgba(0, 0, 0, 0.55); }
}
a.tool-card:focus-visible { outline: 3px solid var(--color-right); outline-offset: 3px; }

/* Planned tools: greyed out, not links. */
.tool-card.soon { background: transparent; border-style: dashed; color: var(--color-text-inactive); backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none; }
.tool-card.soon :is(.tool-name, .tool-desc) { color: var(--color-text-inactive); }
.tool-card.soon .tool-icon { stroke: var(--color-text-inactive); }

/* Theme touches */
body[data-theme="pink"] .tool-card:not(.soon) { box-shadow: 0 6px 0 -2px var(--border-panel); }
body[data-theme="bw"] .beta-badge { border-radius: 0; }
body[data-theme="bw"] .hub-name { font-stretch: 115%; }
body[data-theme="y2k"] .hub-name { text-shadow: 0 0 16px color-mix(in srgb, var(--color-left) 55%, transparent); }
body[data-theme="retro"] .hub-name { text-shadow: 0 0 var(--shadow-blur) color-mix(in srgb, var(--color-left) 60%, transparent); }
body[data-theme="y2k"] .hub-logo { filter: drop-shadow(0 0 8px color-mix(in srgb, var(--color-left) 60%, transparent)); }
body[data-theme="retro"] .hub-logo { filter: drop-shadow(0 0 var(--shadow-blur) color-mix(in srgb, var(--color-left) 60%, transparent)); }
body[data-theme="snap"] .tool-card:not(.soon) { border-color: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: 0 1px 0 rgba(75, 48, 0, 0.08), 0 10px 22px -12px rgba(75, 48, 0, 0.5); }
body[data-theme="snap"] .featured .tool-card { border-color: transparent; }
body[data-theme="rouge"] .tool-card:not(.soon) { box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.25); }

@media (max-width: 860px) {
  .tool-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Phones: the flagship card, then each section as one grouped list; the page scrolls. */
@media (max-width: 600px) {
  .hub-hero { padding: var(--space-1) 0 0; }
  .hub-logo { width: 60px; }
  .hub-name { margin-top: var(--space-3); font-size: 32px; }
  .hub-tagline { margin-top: var(--space-2); font-size: 16px; line-height: 1.4; }
  .hub-privacy { margin-top: var(--space-2); font-size: 13px; line-height: 1.4; }
  .hub-main { gap: var(--space-5); }
  .hub-section-title { margin-bottom: var(--space-2); font-size: 14px; }

  .tool-grid { display: flex; flex-direction: column; gap: 0; }
  .tool-grid > li.featured { margin-bottom: var(--space-4); }
  .tool-grid > li:not(.featured) > .tool-card {
    aspect-ratio: auto; min-height: 0; display: grid; grid-template-columns: 32px minmax(0, 1fr); column-gap: var(--space-4); row-gap: 2px;
    align-items: center; padding: 14px var(--space-4); border-radius: 0; border-top-width: 0;
  }
  .tool-grid > li:not(.featured):first-child > .tool-card,
  .tool-grid > li.featured + li > .tool-card { border-top-width: var(--border-width); border-top-left-radius: var(--radius-panel); border-top-right-radius: var(--radius-panel); }
  .tool-grid > li:last-child > .tool-card { border-bottom-left-radius: var(--radius-panel); border-bottom-right-radius: var(--radius-panel); }
  .tool-grid > li:not(.featured) + li > .tool-card { border-top: 1px solid color-mix(in srgb, var(--border-panel) 55%, transparent); }
  .tool-grid > li:not(.featured) .tool-icon { grid-row: span 2; width: 30px; height: 30px; margin: 0; }
  /* A small arrow says each row opens a tool. */
  .tool-grid > li:not(.featured) > a.tool-card { grid-template-columns: 32px minmax(0, 1fr) 12px; }
  .tool-grid > li:not(.featured) > a.tool-card::after {
    content: ''; grid-column: 3; grid-row: 1 / span 2; width: 8px; height: 8px; justify-self: end;
    border-right: 2px solid var(--color-text-inactive); border-bottom: 2px solid var(--color-text-inactive); transform: rotate(-45deg);
  }
  .featured-art { display: none; }
  .tool-grid > li:not(.featured) .tool-name { font-size: 19px; }
  .tool-grid > li:not(.featured) .tool-desc { font-size: 14px; line-height: 1.35; }
  .tool-grid > li:not(.featured) .beta-badge { position: static; grid-column: 2; justify-self: start; order: 3; margin-top: var(--space-1); padding: 1px 8px; font-size: 11px; }
  .tool-grid > li .tool-card.soon { border-style: dashed; }
  .tool-grid > li:not(.featured) + li > .tool-card.soon { border-top-style: dashed; }
  a.tool-card:active { transform: none; background: color-mix(in srgb, var(--color-right) 12%, var(--color-panel)); }

  .featured .tool-card { justify-content: flex-start; gap: var(--space-2); padding: 20px; }
  .featured .tool-icon { width: 44px; height: 44px; margin-bottom: var(--space-1); }
  .featured .tool-name { font-size: 30px; }
  .featured .tool-desc { font-size: 16px; }
  .beta-badge { top: 12px; right: 12px; padding: 2px 9px; font-size: 11px; }

  /* Paper and shadows look odd stacked in one list: one sheet instead. */
  body[data-theme="snap"] .tool-grid > li:not(.featured) > .tool-card:not(.soon) { box-shadow: none; }
  body[data-theme="pink"] .tool-grid > li:not(.featured) > .tool-card:not(.soon) { box-shadow: none; }
  /* Rouge's corners are two sizes (4px 22px): give each corner its own. */
  body[data-theme="rouge"] .tool-grid > li:not(.featured):first-child > .tool-card,
  body[data-theme="rouge"] .tool-grid > li.featured + li > .tool-card { border-top-left-radius: 4px; border-top-right-radius: 22px; }
  body[data-theme="rouge"] .tool-grid > li:last-child > .tool-card { border-bottom-left-radius: 22px; border-bottom-right-radius: 4px; }
  /* The page scrolls here, so the footer may wrap. */
  .tool-footer { padding-top: var(--space-2); }
}

/* Reduce motion: cards light up without lifting. */
@media (prefers-reduced-motion: reduce) {
  a.tool-card:hover, a.tool-card:active { transform: none; }
}
