/**
 * Shared styles for the StudyKit media tools.
 *
 * The nine media pages are deliberately one class, not nine, with the differences
 * carried by markup and a per-tool script. Two things follow from that.
 *
 * First, colour is expressed only through the custom properties on
 * .sk-media-page. Dark mode is therefore a single rule that re-points six
 * variables instead of a dozen per-selector overrides, which is what makes it
 * safe to add a ninth tool later: a new component inherits a correct dark
 * palette simply by using var(--sk-*) like everything else, and cannot be
 * forgotten in a dark block the way an extra selector can.
 *
 * Second, the accent splits into three roles rather than one. On a light panel
 * the brand purple works as a button background with white text, but the same
 * colour as link text on a dark surface fails contrast, and white on the
 * darkened button fails too. --sk-accent is text on a surface, --sk-on-accent
 * is text on a button, and they are set independently per scheme.
 */

.sk-media-page {
  --sk-ink: #28323a;
  --sk-muted: #5c6871;
  --sk-accent: #68438b;
  --sk-accent-strong: #452b61;
  --sk-on-accent: #ffffff;
  --sk-accent-bg: #68438b;
  --sk-line: #dfe3e8;
  --sk-surface: #ffffff;
  --sk-soft: #f7f5fa;
  --sk-ok: #1f6b45;
  --sk-warn: #8a5a12;
  --sk-error: #a6324a;
  --sk-shadow: 0 1px 2px rgba(20, 24, 30, 0.06), 0 6px 18px rgba(20, 24, 30, 0.05);

  max-width: 1140px;
  margin: 0 auto;
  padding: 30px 20px 60px;
  color: var(--sk-ink);
  line-height: 1.65;
  font-family: inherit;
}

.sk-media-page * {
  box-sizing: border-box;
}

/* One rule re-themes the entire family. Anything using var(--sk-*) follows
   automatically; a hard-coded hex would opt out and fail the colour audit. */
html[data-sk-scheme="dark"] .sk-media-page {
  --sk-ink: #e9edf2;
  --sk-muted: #aab5c1;
  --sk-accent: #c79bf0;
  --sk-accent-strong: #e6cbf8;
  --sk-on-accent: #1a1220;
  --sk-accent-bg: #a679dd;
  --sk-line: #333d48;
  --sk-surface: #222a33;
  --sk-soft: #1a2028;
  --sk-ok: #6fd6a2;
  --sk-warn: #e8bd6a;
  --sk-error: #ff9db2;
  --sk-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.28);
}

.sk-media-page h1,
.sk-media-page h2,
.sk-media-page h3 {
  color: var(--sk-accent-strong);
}

.sk-media-page a {
  color: var(--sk-accent);
}

.sk-media-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 22px;
  align-items: start;
  margin-top: 24px;
}

.sk-media-layout[data-stack="true"] {
  grid-template-columns: minmax(0, 1fr);
}

.sk-media-panel {
  padding: 24px;
  border: 1px solid var(--sk-line);
  border-radius: 20px;
  background: var(--sk-surface);
  box-shadow: var(--sk-shadow);
}

.sk-media-panel > h2 {
  margin: 0 0 10px;
  font-size: 1.35rem;
}

.sk-media-lead {
  margin: 0 0 18px;
  color: var(--sk-muted);
  font-size: 0.93rem;
}

/* Drop zone doubles as the file input's button, so it carries the button
   styling and the hover affordance. */
.sk-media-drop {
  display: block;
  padding: 26px 20px;
  border: 2px dashed var(--sk-line);
  border-radius: 16px;
  background: var(--sk-soft);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.sk-media-drop:hover,
.sk-media-drop:focus-visible,
.sk-media-drop[data-drag="true"] {
  border-color: var(--sk-accent);
  background: var(--sk-surface);
}

.sk-media-drop:focus-visible {
  outline: 3px solid var(--sk-accent);
  outline-offset: 2px;
}

.sk-media-drop strong {
  display: block;
  color: var(--sk-accent-strong);
  font-size: 1.02rem;
}

.sk-media-drop span {
  display: block;
  margin-top: 6px;
  color: var(--sk-muted);
  font-size: 0.9rem;
}

.sk-media-drop small {
  display: block;
  margin-top: 8px;
  color: var(--sk-muted);
  font-size: 0.8rem;
}

.sk-media-file {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: baseline;
  margin-top: 12px;
  padding: 10px 14px;
  border: 1px solid var(--sk-line);
  border-radius: 12px;
  background: var(--sk-soft);
  font-size: 0.86rem;
}

.sk-media-file strong {
  color: var(--sk-ink);
  word-break: break-all;
}

.sk-media-file span {
  color: var(--sk-muted);
}

.sk-media-controls {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.sk-media-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
}

.sk-media-field {
  display: block;
}

.sk-media-field > span {
  display: block;
  margin-bottom: 6px;
  color: var(--sk-ink);
  font-size: 0.86rem;
  font-weight: 700;
}

.sk-media-field small {
  display: block;
  margin-top: 5px;
  color: var(--sk-muted);
  font-size: 0.78rem;
  font-weight: 400;
}

.sk-media-page select,
.sk-media-page input[type="text"],
.sk-media-page input[type="number"] {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--sk-line);
  border-radius: 11px;
  background: var(--sk-surface);
  color: var(--sk-ink);
  font: inherit;
  font-size: 0.92rem;
}

/* A native colour field paints its own background and ignores the one set
   here, which leaves a white box sitting in a dark panel. Turning the native
   appearance off makes the padding around the swatch use --sk-surface, so the
   control follows the scheme while the swatch still shows the chosen colour. */
.sk-media-page input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 44px;
  padding: 4px;
  border: 1px solid var(--sk-line);
  border-radius: 11px;
  background: var(--sk-surface);
  cursor: pointer;
}

.sk-media-page input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.sk-media-page input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 7px;
}

.sk-media-page input[type="range"] {
  width: 100%;
  accent-color: var(--sk-accent-bg);
}

.sk-media-range {
  display: flex;
  gap: 10px;
  align-items: center;
}

.sk-media-range output {
  min-width: 62px;
  padding: 4px 8px;
  border: 1px solid var(--sk-line);
  border-radius: 9px;
  background: var(--sk-soft);
  color: var(--sk-ink);
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.sk-media-check {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  color: var(--sk-muted);
  font-size: 0.86rem;
}

.sk-media-check input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  flex: 0 0 auto;
  accent-color: var(--sk-accent-bg);
}

.sk-media-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.sk-media-button {
  min-height: 44px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--sk-accent-bg);
  color: var(--sk-on-accent) !important;
  font: 800 0.9rem inherit;
  text-decoration: none !important;
  cursor: pointer;
}

.sk-media-button:hover:not(:disabled) {
  filter: brightness(1.08);
}

.sk-media-button.secondary {
  border-color: var(--sk-line);
  background: var(--sk-surface);
  color: var(--sk-accent-strong) !important;
}

.sk-media-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.sk-media-page :focus-visible {
  outline: 3px solid var(--sk-accent);
  outline-offset: 2px;
}

.sk-media-status {
  min-height: 24px;
  margin: 16px 0 0;
  color: var(--sk-muted);
  font-size: 0.9rem;
}

.sk-media-status[data-state="ok"] {
  color: var(--sk-ok);
  font-weight: 700;
}

.sk-media-status[data-state="warn"] {
  color: var(--sk-warn);
  font-weight: 700;
}

.sk-media-status[data-state="error"] {
  color: var(--sk-error);
  font-weight: 700;
}

.sk-media-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  padding: 14px;
  border: 1px solid var(--sk-line);
  border-radius: 16px;
  background: var(--sk-soft);
  /* Checkerboard makes a transparent PNG visibly transparent instead of
     looking like an empty white box, which matters for watermark and redaction
     output where alpha is the point. */
  background-image:
    linear-gradient(45deg, rgba(128, 128, 128, 0.14) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(128, 128, 128, 0.14) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(128, 128, 128, 0.14) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(128, 128, 128, 0.14) 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}

.sk-media-stage canvas,
.sk-media-stage img,
.sk-media-stage video {
  display: block;
  max-width: 100%;
  max-height: 560px;
  height: auto;
  border-radius: 8px;
}

/* The picked background colour, shown beside the cut-out. A colour swatch needs
   two borders to be readable on a light stage: one light inside a dark one,
   because a white swatch on a near-white card would otherwise vanish. */
.sk-media-key {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 0;
  color: var(--sk-muted);
  font-size: 0.86rem;
  font-weight: 600;
}

.sk-media-swatch {
  display: inline-block;
  width: 30px;
  height: 30px;
  border: 1px solid var(--sk-line);
  border-radius: 8px;
  background: transparent;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.7) inset;
}

.sk-media-empty {
  margin: 0;
  color: var(--sk-muted);
  font-style: italic;
  text-align: center;
}

/* Side-by-side before/after. The compare tools need to see the difference, and
   stacking the two on narrow screens keeps both usable. */
.sk-media-compare {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.sk-media-compare figure {
  margin: 0;
}

.sk-media-compare figcaption {
  margin-bottom: 6px;
  color: var(--sk-muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.sk-media-compare .sk-media-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 170px;
  padding: 8px;
  border: 1px solid var(--sk-line);
  border-radius: 12px;
  background: var(--sk-soft);
  background-image: none;
}

.sk-media-compare canvas {
  max-height: 400px;
}

/* The paint canvas takes pointer drags, so it must not also scroll the page on
   touch, and it needs to advertise that it is a target rather than an image. */
.sk-media-stage canvas[data-paint="true"] {
  touch-action: none;
  cursor: crosshair;
  max-height: 520px;
}

.sk-media-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.sk-media-stat {
  flex: 1 1 120px;
  padding: 12px 14px;
  border: 1px solid var(--sk-line);
  border-radius: 12px;
  background: var(--sk-soft);
}

.sk-media-stat b {
  display: block;
  color: var(--sk-ink);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.sk-media-stat span {
  color: var(--sk-muted);
  font-size: 0.78rem;
}

.sk-media-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sk-media-chip {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--sk-line);
  border-radius: 999px;
  background: var(--sk-surface);
  color: var(--sk-ink) !important;
  font: 700 0.83rem inherit;
  cursor: pointer;
}

.sk-media-chip[aria-pressed="true"] {
  border-color: var(--sk-accent-bg);
  background: var(--sk-accent-bg);
  color: var(--sk-on-accent) !important;
}

.sk-media-text {
  width: 100%;
  min-height: 190px;
  padding: 12px;
  border: 1px solid var(--sk-line);
  border-radius: 12px;
  background: var(--sk-surface);
  color: var(--sk-ink);
  font: 0.9rem/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: vertical;
}

.sk-media-note {
  margin-top: 24px;
  padding: 18px 20px;
  border-left: 4px solid var(--sk-accent);
  border-radius: 8px;
  background: var(--sk-soft);
  color: var(--sk-muted);
  font-size: 0.92rem;
}

.sk-media-note strong {
  color: var(--sk-ink);
}

.sk-media-guide {
  margin-top: 34px;
}

.sk-media-guide h2 {
  font-size: 1.45rem;
}

.sk-media-guide-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.sk-media-guide article {
  padding: 20px;
  border: 1px solid var(--sk-line);
  border-radius: 16px;
  background: var(--sk-surface);
}

.sk-media-guide h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.sk-media-guide p {
  margin: 0;
  color: var(--sk-muted);
  font-size: 0.93rem;
}

.sk-media-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 9px 18px;
  margin-top: 30px;
}

/* Screen recorder only. The pulse is the single signal that recording is live,
   so it is animation-based and also carries text, rather than colour alone. */
.sk-media-rec-indicator {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: var(--sk-error);
  font-size: 0.9rem;
  font-weight: 700;
}

.sk-media-rec-indicator::before {
  content: "";
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: currentColor;
  animation: sk-media-pulse 1.1s ease-in-out infinite;
}

@keyframes sk-media-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

@media (prefers-reduced-motion: reduce) {
  .sk-media-rec-indicator::before {
    animation: none;
  }
  .sk-media-page * {
    scroll-behavior: auto;
  }
}

.sk-media-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

@media (max-width: 860px) {
  .sk-media-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .sk-media-guide-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
