/* Outer-space theme. Every color is plain CSS: no images to download. */

/* THE LOOK, IN ONE PLACE. These colors are the single source for the site AND the space postcard:
   postcard.js reads them from here when it draws (readTheme), so changing one here changes both.
   Add a new shared color here and to THEME_TOKENS in postcard.js. */
:root {
  --sky-top: #0b0a2a;
  --sky-middle: #1a1450;
  --sky-bottom: #2b1b5e;
  --star-gold: #ffe9a8;
  --star-blue: #cfe3ff;
  --planet-light: #b4d3a4;
  --planet-middle: #62a07c;
  --planet-dark: #254f58;
  --planet-hidden: 0.2; /* how far the planet sticks out past the corner, as a fraction of its width */
  --ink: #f1eeff;       /* main text and headings */
  --accent: #ffd84d;    /* yellow: Tintishew words, buttons, links */
  --soft: #c9bfff;      /* quieter text */
}

/* A clear ring on whatever has the keyboard focus (for people who don't use a mouse) */
:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  padding: 16px;
  min-height: 100vh;
  box-sizing: border-box;
  font-family: system-ui, sans-serif;
  font-size: 1.25rem;
  color: var(--ink);
  /* The night sky: dark blue at the top, purple near the bottom */
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-middle) 55%, var(--sky-bottom) 100%) fixed;
  /* A column, so the footer can sit at the bottom of the page even when the content is short */
  display: flex;
  flex-direction: column;
}

/* A planet peeking in from the top-trailing corner. Its colors are the --planet-* tokens above
   (the color chooser in planet-picker.js, not loaded for now, changes those). The postcard draws
   the same planet: light spot at 30% 30%, the middle color at 55%, the dark color at the edge. */

html::before {
  content: "";
  position: fixed;
  top: calc(-1 * var(--planet-hidden) * var(--planet-size));
  right: calc(-1 * var(--planet-hidden) * var(--planet-size));
  --planet-size: clamp(130px, 42vmin, 620px); /* about 160px on a phone */
  width: var(--planet-size);
  height: var(--planet-size);
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--planet-light), var(--planet-middle) 55%, var(--planet-dark));
  z-index: -1; /* above the stars (-2), so they don't show through */
  pointer-events: none;
}

/* The planet color chooser (see planet-picker.js; not shown for now) */
.planet-picker {
  position: fixed;
  left: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 0.9rem;
  background: rgba(15, 12, 50, 0.85);
  border-radius: 999px;
}

.planet-picker button {
  width: 28px;
  height: 28px;
  cursor: pointer;
  border: 2px solid var(--ink);
  border-radius: 50%;
}

/* Stars: tiny glowing dots, two layers of different sizes */
body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
}

body::before {
  background-image:
    radial-gradient(1.5px 1.5px at 20px 30px, #fff, transparent),
    radial-gradient(1px 1px at 90px 140px, #fff, transparent),
    radial-gradient(2px 2px at 160px 70px, var(--star-gold), transparent),
    radial-gradient(1px 1px at 230px 200px, #fff, transparent),
    radial-gradient(1.5px 1.5px at 300px 110px, var(--star-blue), transparent);
  background-size: 320px 240px;
}

body::after {
  background-image:
    radial-gradient(1.5px 1.5px at 60px 90px, #fff, transparent),
    radial-gradient(2px 2px at 200px 40px, #fff, transparent),
    radial-gradient(1px 1px at 140px 190px, var(--star-gold), transparent),
    radial-gradient(1.5px 1.5px at 270px 170px, #fff, transparent);
  background-size: 410px 290px;
  animation: twinkle 4s ease-in-out infinite alternate;
}

@keyframes twinkle {
  from { opacity: 0.35; }
  to { opacity: 1; }
}

/* People who prefer less motion get steady stars */
@media (prefers-reduced-motion: reduce) {
  body::after {
    animation: none;
  }
}

/* A dark, see-through panel keeps the text easy to read over the stars. It has no border and
   fades to clear at its edges. (The panel is a ::before layer, so the fade doesn't touch the text.) */
main {
  --fade: clamp(14px, 4vw, 56px);
  --fade-up-down: 40px;
  position: relative;
  isolation: isolate;
  box-sizing: border-box;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: var(--fade-up-down) calc(var(--fade) + 8px);
}

main.wide {
  max-width: 1400px;
}

/* On a big window, start with the translator in the middle of the screen */
body:has(main.wide) {
  display: flex;
  flex-direction: column;
}

body:has(main.wide) main {
  margin: auto;
}

main::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: transparent; /* TRY-OUT: was rgba(15, 12, 50, 0.82) */
  -webkit-mask-image:
    linear-gradient(to right, transparent, #000 var(--fade), #000 calc(100% - var(--fade)), transparent),
    linear-gradient(to bottom, transparent, #000 var(--fade-up-down), #000 calc(100% - var(--fade-up-down)), transparent);
  -webkit-mask-composite: source-in;
  mask-image:
    linear-gradient(to right, transparent, #000 var(--fade), #000 calc(100% - var(--fade)), transparent),
    linear-gradient(to bottom, transparent, #000 var(--fade-up-down), #000 calc(100% - var(--fade-up-down)), transparent);
  mask-composite: intersect;
}

h1 {
  margin-bottom: 0;
}

/* How to say the name of the language: big and easy to spot */
.say-it {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 8px 0 4px;
}

.say-label {
  color: var(--soft);
  font-size: 1.1rem;
}

.say-word {
  color: var(--accent);
  font-size: 2rem;
  font-weight: bold;
  letter-spacing: 0.04em;
}

.say-soft {
  font-weight: normal;
  opacity: 0.85;
}

.subtitle {
  margin-top: 4px;
  color: var(--soft);
}

a {
  color: var(--accent);
}

label {
  display: block;
  margin: 20px 0 6px;
  font-weight: bold;
}

textarea,
output,
input {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-height: 10rem;
  padding: 14px;
  font: inherit;
  color: #2b2350;
  background: white;
  border: 3px solid #b9a8ff;
  border-radius: 14px;
}

input {
  min-height: 0;
}

textarea,
output {
  font-size: 1.4rem;
}

output {
  white-space: pre-wrap;
}

output:empty::before {
  content: "Tintishew appears here…";
  color: #6f65a3;
}

/* A guess for a word the dictionary doesn't know yet (made from the alphabet) */
.candidate {
  font-style: italic;
  color: #7b2fbe;
  text-decoration: underline dotted;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

/* A word we kept as typed because it is not in the dictionary */
.unknown {
  background: #ffe3ef;
  border-bottom: 3px dotted #d6336c;
  border-radius: 4px;
}

/* An unknown word shown as the translation of a similar word I do know */
.similar {
  background: #ffe3ef;
  border-bottom: 3px dotted #d6336c;
  border-radius: 4px;
  font-style: italic;
}

/* A word that came from splitting a contraction (don't -> do not) */
.expanded {
  border-bottom: 2px dashed #8d7bd8;
}

.box-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.side-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* The two boxes: stacked on narrow screens, side by side on wide ones.
   (The browser re-lays this out by itself when the window or phone turns.) */
.translator {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 720px) {
  .translator {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    column-gap: 16px;
    align-items: start;
  }

  /* Level with the English / Tintishew headings */
  .translator .swap-row {
    margin-top: 14px;
  }
}

/* A small, quiet arrows button (its words are only for screen readers and the hover tip) */
.swap-button {
  display: inline-flex;
  padding: 6px;
  color: var(--soft);
  cursor: pointer;
  background: transparent;
  border: 2px solid #6f65a3;
  border-radius: 999px;
}

.swap-button:hover,
.swap-button:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
}

.swap-button .icon {
  width: 1.4rem;
  height: 1.4rem;
  margin: 0;
}

/* Icons (see icons.js) */
.icon {
  width: 1.25em;
  height: 1.25em;
  margin-right: 0.45em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.22em;
}

.speak .icon {
  width: 28px;
  height: 28px;
  margin: 0;
}

/* The arrows point up and down when the boxes are stacked */
@media (max-width: 719.98px) {
  .swap-row .icon {
    transform: rotate(90deg);
  }
}

summary .icon {
  color: var(--soft);
}

.speak {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  color: #2b2350;
  cursor: pointer;
  background: var(--accent);
  border: 3px solid #e0b800;
  border-radius: 14px;
}

.speak:hover:not(:disabled),
.speak:focus-visible {
  background: #ffe680;
}

.speak:disabled {
  opacity: 0.5;
  cursor: default;
}

.button {
  font: inherit;
  font-size: 1.1rem;
  padding: 10px 16px;
  color: #2b2350;
  cursor: pointer;
  background: var(--accent);
  border: 3px solid #e0b800;
  border-radius: 14px;
}

.button:hover:not(:disabled),
.button:focus-visible {
  background: #ffe680;
}

.button:disabled {
  opacity: 0.5;
  cursor: default;
}

/* The microphone while it is listening */
.speak.listening {
  background: #ff8fb8;
  border-color: #d6336c;
  animation: pulse 1s ease-in-out infinite alternate;
}

@keyframes pulse {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
  .speak.listening {
    animation: none;
  }
}

/* A link that looks like a button */
a.button {
  display: inline-block;
  text-decoration: none;
}

a.button[aria-disabled] {
  opacity: 0.5;
  cursor: default;
}

details {
  margin-top: 16px;
  color: var(--soft);
  font-size: 1rem;
}

summary {
  cursor: pointer;
}

code {
  padding: 1px 6px;
  color: #2b2350;
  background: #e7e0ff;
  border-radius: 6px;
}

/* The postcard picture and the "too long" message */
/* The title with a close button at its end, as wide as the picture below it */
.postcard-heading {
  max-width: 640px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.close-button {
  display: inline-flex;
  padding: 6px;
  color: var(--soft);
  cursor: pointer;
  background: transparent;
  border: 2px solid #6f65a3;
  border-radius: 999px;
}

.close-button:hover,
.close-button:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
}

.close-button .icon {
  width: 1.4rem;
  height: 1.4rem;
  margin: 0;
}

#postcard-preview {
  display: block;
  width: 100%;
  max-width: 640px; /* big enough to read, without filling the screen */
  margin: 8px 0 12px;
  border-radius: 14px;
}

#too-long-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

mark {
  color: #2b2350;
  background: #ffe3ef;
  border-bottom: 3px dotted #d6336c;
  border-radius: 4px;
}

.swap-row {
  margin-top: 16px;
  text-align: center;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

#message,
#notice,
#word-message,
#word-warning,
#storage-note {
  min-height: 1.5rem;
  margin: 8px 0;
  color: #ffc2dd;
}

/* History, the words to review, and My Words */
#history,
#review-list,
#mywords {
  list-style: none;
  padding: 0;
  margin: 12px 0;
}

#history li,
#review-list li,
#mywords li {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 14px;
}

#history .texts,
#review-list .texts,
#mywords .texts {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

#history .line {
  margin: 2px 0;
}

#history .language {
  color: var(--soft);
  font-size: 0.85rem;
  margin-right: 6px;
}


/* Buttons at the end of a row in the review list or My Words */
.row-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

#review-list li,
#mywords li {
  flex-wrap: wrap;
}

.form-actions {
  margin-top: 12px;
}

/* The export page */
textarea[readonly] {
  min-height: 12rem;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.9rem;
}

/* Table and "try it" box on the alphabet page */
table {
  border-collapse: collapse;
  width: 100%;
  color: #2b2350;
  background: white;
}

caption {
  color: var(--soft);
}

th,
td {
  padding: 8px 12px;
  text-align: left;
  border: 2px solid #b9a8ff;
}

th {
  background: #e7e0ff;
}

footer {
  margin-top: auto;
  padding-top: 24px;
  font-size: 0.9rem;
  text-align: center;
  color: var(--soft);
}
