/* The parent page's own layout, on top of tokens.css and design-system.css, which are copies from the design system. */

/* Pages */

.page > * + * {
  margin-top: var(--space-4);
}

.page > section {
  margin-top: var(--space-8);
}

.page > .back + * {
  margin-top: var(--space-2);
}

section > * + *,
.panel:not(.child-form) > * + * {
  margin-top: var(--space-3);
}

.panel h3 {
  margin-top: var(--space-5);
}

h2 .small,
h3 .small {
  font: 400 14px/20px var(--font-body);
}

.back {
  display: inline-flex;
  gap: var(--space-1);
  align-items: center;
  min-height: var(--control-height);
  color: var(--ink-muted);
  text-decoration: none;
}

.back:hover {
  color: var(--ink);
}

.external {
  white-space: nowrap;
}

.external .icon {
  vertical-align: -0.2em;
}

.is-pending button,
form.is-pending {
  opacity: 0.6;
}

/* Signing up and in */

.sign-up {
  display: grid;
  gap: var(--space-5);
  justify-items: start;
  max-width: 640px;
}

.sign-up > .panel {
  width: 100%;
}

.agreement {
  max-width: 640px;
}

.agreement ul {
  margin-bottom: 0;
  padding-left: var(--space-5);
}

.agreement li + li {
  margin-top: var(--space-2);
}

.authenticator-qr {
  display: grid;
  gap: var(--space-3);
  justify-items: start;
}

.authenticator-qr img,
.authenticator-qr-space {
  width: 200px;
  height: 200px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
}

.authenticator-qr code {
  color: var(--ink);
  font-size: 15px;
  overflow-wrap: anywhere;
}

/* Account */

.account-panel .theme-choice {
  max-width: 360px;
}

/* Devices */

.device-list {
  display: grid;
  gap: var(--space-3);
  margin-bottom: 0;
  padding: 0;
  list-style: none;
}

.device-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.panel.device-row > * + * {
  margin-top: 0;
}

.device-name {
  margin: 0;
  overflow-wrap: anywhere;
}

.device-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Parents */

.invite-waiting {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.invite-waiting p {
  margin: 0;
}

/* Children */

.child-form {
  display: grid;
  gap: var(--space-5);
  justify-items: start;
  max-width: 640px;
}

.avatar-picker {
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
}

.avatar-picker legend {
  padding: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
}

.avatar-grid {
  margin-top: var(--space-3);
}

/* Channels */

.search-small {
  flex: 1;
  max-width: 420px;
}

.avatar-large {
  width: 96px;
  height: 96px;
}

.channel-header {
  display: flex;
  gap: var(--space-4);
  align-items: center;
}

.channel-header h1 {
  margin-bottom: var(--space-1);
}

.channel-header .badge {
  margin-left: var(--space-1);
}

.description {
  white-space: pre-line;
}

.result-list {
  display: grid;
  gap: var(--space-3);
}

.clamp {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  white-space: normal;
}

.mode-grid form {
  display: flex;
}

.mode {
  flex: 1;
}

.danger-zone {
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
}

/* Rules */

.page > section .rule-board + * {
  margin-top: var(--space-4);
}

.rule-form {
  margin-top: var(--space-3);
}

.panel > .rule-form {
  margin-top: 0;
}

.rule-fields {
  display: grid;
  gap: var(--space-3);
}

.rule-value {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.rule-value label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.rule-value input[type="number"] {
  width: 90px;
}

.rule-value input[type="text"] {
  flex: 1 1 180px;
  min-width: 0;
}

.rule-value .button {
  margin-left: auto;
}

/* Only the field for the chosen kind of rule shows. */
.rule-value .for-words,
.rule-value .for-minutes,
.rule-value .for-date {
  display: none;
}

.rule-form:has(input[value="title_words"]:checked) .rule-value .for-words {
  display: block;
}

.rule-form:has(input[value="longer_than"]:checked) .rule-value .for-minutes,
.rule-form:has(input[value="shorter_than"]:checked) .rule-value .for-minutes {
  display: inline-flex;
}

.rule-form:has(input[value="published_before"]:checked) .rule-value .for-date,
.rule-form:has(input[value="published_after"]:checked) .rule-value .for-date {
  display: block;
}

.rule-tabs {
  margin-bottom: var(--space-5);
}

.add-channel {
  display: grid;
  gap: var(--space-3);
}

.shared-rule-choices {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
}

.shared-rule-choices legend {
  margin-bottom: var(--space-2);
  padding: 0;
  font-weight: 600;
}

.shared-rule-choice {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
  cursor: pointer;
}

.shared-rule-choice input {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 0;
}

.rule-preview:not(:empty) {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-hover);
}

.rule-preview > div {
  display: grid;
  gap: var(--space-3);
}

.rule-preview .video-grid {
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

/* Videos */

.list-header {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  align-items: center;
  justify-content: space-between;
}

.list-header h2 {
  margin: 0;
}

.bulk {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  align-items: center;
}

.video-check {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: var(--space-5);
  align-items: start;
}

.video-check .thumb img {
  border-radius: var(--radius-md);
}

.video-mini {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  overflow: hidden;
  color: inherit;
  font-size: 14px;
  line-height: 20px;
  text-decoration: none;
}

.video-mini img {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  background: var(--surface-media);
  object-fit: cover;
}

/* Always a half card at the edge, whatever the width, so that a row looks like it carries on. */
.preview-row-frame {
  --preview-cards: 4.5;
  --preview-card: calc((100cqw - (var(--preview-cards) - 0.5) * var(--space-3)) / var(--preview-cards));
  position: relative;
  container-type: inline-size;
}

.preview-row {
  display: grid;
  grid-auto-columns: var(--preview-card);
  grid-auto-flow: column;
  gap: var(--space-3);
  overflow-x: auto;
  padding-bottom: var(--space-2);
  scroll-snap-type: x proximity;
}

.preview-row .video-mini {
  scroll-snap-align: start;
}

@media (prefers-reduced-motion: no-preference) {
  .preview-row {
    scroll-behavior: smooth;
  }
}

/* Halfway down the thumbnails, and solid so that it stands out on any of them. */
.preview-row-arrow {
  position: absolute;
  top: calc(var(--preview-card) * 9 / 32);
  width: var(--control-height);
  padding: 0;
  border-color: transparent;
  background: var(--ink);
  color: var(--surface);
  transform: translateY(-50%);
}

.preview-row-arrow:hover {
  background: var(--ink-muted);
}

.preview-row-before {
  left: var(--space-2);
}

.preview-row-after {
  right: var(--space-2);
}

/* Activity */

.activity-summary {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: var(--space-5);
  align-items: end;
}

.panel.activity-summary > * + * {
  margin-top: 0;
}

/* Fixed, so that the two tables' columns line up whatever is in them. Wide enough on a phone to leave the video its 260px. */
.activity-table {
  min-width: 784px;
  table-layout: fixed;
}

.activity-detail {
  width: 210px;
}

.activity-time {
  width: 120px;
}

.activity-when {
  width: 170px;
}

.day:focus-visible {
  background: var(--surface-hover);
}

.day-tip {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  z-index: 1;
  display: none;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--surface);
  font-size: 13px;
  font-weight: 500;
  line-height: 18px;
  white-space: nowrap;
  transform: translateX(-50%);
}

.day:first-child .day-tip {
  left: 0;
  transform: none;
}

.day:last-child .day-tip {
  right: 0;
  left: auto;
  transform: none;
}

.day:hover .day-tip,
.day:focus-visible .day-tip {
  display: block;
}

@media (max-width: 900px) {
  .preview-row-frame {
    --preview-cards: 3.5;
  }
}

@media (max-width: 600px) {
  .activity-summary {
    grid-template-columns: minmax(0, 1fr);
  }

  .preview-row-frame {
    --preview-cards: 1.5;
  }

  .result-actions {
    width: 100%;
  }

  .result-actions .button {
    display: flex;
  }

  .avatar-large {
    width: 72px;
    height: 72px;
  }
}
