/*
 * Design tokens and the frame of the application.
 *
 * Every colour, size and radius the editor uses is declared once here. The
 * values start from the site's own look, and when the theme is in place it will
 * declare the same names, so the editor inherits them instead of repeating them.
 */

:root {
	/* Colour */
	--se-ink: #1a1a1a;
	--se-text: #3c3c3c;
	--se-muted: #54595f;

	/*
	 * Two reds, not one. The brand red is light: white on it reaches 2.95:1,
	 * which fails AA for text of any size, so it is kept for what it is good
	 * at (a border, a highlight, a dash) and a darker member of the same
	 * family carries anything a person has to read or press. 5.5:1.
	 */
	--se-accent: #f86d71;
	--se-action: #c0353b;
	--se-action-ink: #ffffff;
	--se-action-hover: #a32930;

	--se-surface: #ffffff;
	--se-bg: #fafafa;
	--se-line: #e6e6e6;
	--se-line-strong: #c9c9c9;
	--se-focus: #1a73e8;
	--se-warn: #d08700;

	/* Type */
	--se-font-ui: "Heebo", "Assistant", system-ui, sans-serif;
	--se-font-head: "Assistant", "Heebo", system-ui, sans-serif;
	--se-font-mono: ui-monospace, "SFMono-Regular", "Consolas", monospace;
	--se-size-base: 15px;
	--se-size-small: 13px;

	/*
	 * The row geometry is shared with cue-table.js, which computes the height
	 * of every row from it rather than measuring. The two have to agree.
	 */
	--se-line-height: 22px;
	--se-text-padding: 4px;
	--se-row-padding: 5px;

	/* Shape and rhythm */
	--se-radius: 6px;
	--se-radius-lg: 10px;
	--se-gap: 12px;
	--se-bar-height: 52px;

	color-scheme: light;
}

*,
*::before,
*::after {
	box-sizing: border-box;
}

html,
body {
	height: 100%;
}

body.se-body {
	margin: 0;
	background: var(--se-bg);
	color: var(--se-text);
	font-family: var(--se-font-ui);
	font-size: var(--se-size-base);
	line-height: 1.55;
	-webkit-text-size-adjust: 100%;
}

/*
 * Latin inside a Hebrew interface: time codes, file names and numeric fields
 * are left to right even when the surrounding line is not. plaintext lets each
 * line pick its own direction from its first strong character, which is what
 * keeps a full stop or a bracket at the end of a subtitle line where the writer
 * put it.
 */
.se-ltr {
	direction: ltr;
	text-align: left;
	unicode-bidi: isolate;
}

.se-auto {
	unicode-bidi: plaintext;
}

input[type="email"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="time"] {
	direction: ltr;
	text-align: left;
}

.se-visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* Layout -------------------------------------------------------------- */

.se-app {
	display: flex;
	flex-direction: column;
	height: 100%;
}

.se-bar {
	display: flex;
	align-items: center;
	gap: var(--se-gap);
	height: var(--se-bar-height);
	padding: 0 16px;
	background: var(--se-surface);
	border-bottom: 1px solid var(--se-line);
	flex: 0 0 auto;
}

.se-bar__title {
	margin: 0;
	font-family: var(--se-font-head);
	font-size: 17px;
	font-weight: 700;
	color: var(--se-ink);
}

.se-bar__spacer {
	flex: 1 1 auto;
}

.se-bar__note {
	font-size: var(--se-size-small);
	color: var(--se-muted);
}

.se-main {
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: var(--se-gap);
	padding: 16px;
}

/*
 * A flex child refuses to shrink below the natural width of what is inside it
 * unless it is told it may. Without this the list pushes the page wider than
 * the window, which in a right to left layout also means it opens scrolled.
 */
.se-main > * {
	min-width: 0;
}

.se-main--centred {
	align-items: center;
	justify-content: center;
}

/* Empty state --------------------------------------------------------- */

.se-drop {
	width: min(560px, 100%);
	background: var(--se-surface);
	border: 2px dashed var(--se-line-strong);
	border-radius: var(--se-radius-lg);
	padding: 40px 28px;
	text-align: center;
	transition: border-color 0.15s ease, background-color 0.15s ease;
}

.se-drop.is-over {
	border-color: var(--se-accent);
	background: #fff7f7;
}

.se-drop__title {
	margin: 0 0 6px;
	font-family: var(--se-font-head);
	font-size: 20px;
	font-weight: 700;
	color: var(--se-ink);
}

.se-drop__text {
	margin: 0 0 20px;
	color: var(--se-muted);
}

.se-drop__formats {
	margin: 18px 0 0;
	font-size: var(--se-size-small);
	color: var(--se-muted);
}

/* A line of Latin inside a centred block needs the direction, not the alignment. */
.se-drop__formats.se-ltr {
	text-align: center;
}

/* Controls ------------------------------------------------------------ */

.se-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 40px;
	padding: 0 20px;
	border: 1px solid transparent;
	border-radius: var(--se-radius);
	background: var(--se-action);
	color: var(--se-action-ink);
	font: inherit;
	font-weight: 500;
	cursor: pointer;
}

.se-button:hover {
	background: var(--se-action-hover);
}

.se-button--quiet {
	background: transparent;
	color: var(--se-ink);
	border-color: var(--se-line-strong);
}

.se-button--quiet:hover {
	background: var(--se-bg);
}

.se-button--primary {
	background: var(--se-action);
	color: var(--se-action-ink);
}

.se-button--primary:hover {
	background: var(--se-action-hover);
}

.se-button--icon {
	min-width: 36px;
	padding: 0 10px;
	font-size: 17px;
	line-height: 1;
}

.se-button[disabled] {
	opacity: 0.4;
	cursor: default;
}

.se-button--quiet[disabled]:hover {
	background: transparent;
}

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

/* Toolbar ------------------------------------------------------------- */

.se-toolbar {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 20px;
	flex-wrap: wrap;
	padding: 8px 12px;
	background: var(--se-surface);
	border: 1px solid var(--se-line);
	border-radius: var(--se-radius);
}

.se-toolbar__group {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
	min-width: 0;
}

.se-toolbar__group--end {
	margin-inline-start: auto;
}

.se-toolbar__label {
	font-size: var(--se-size-small);
	color: var(--se-muted);
}

.se-field {
	min-height: 36px;
	max-width: 180px;
	padding: 0 8px;
	border: 1px solid var(--se-line-strong);
	border-radius: var(--se-radius);
	background: var(--se-surface);
	font: inherit;
	color: var(--se-text);
}

.se-field--narrow {
	width: 64px;
	text-align: center;
}

/* The list ------------------------------------------------------------ */

.se-list {
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	flex-direction: column;
	background: var(--se-surface);
	border: 1px solid var(--se-line);
	border-radius: var(--se-radius);
	overflow: hidden;
}

.se-row {
	display: grid;
	grid-template-columns: 46px 112px 112px 54px 92px minmax(0, 1fr) 100px;
	align-items: start;
	column-gap: 4px;
}

.se-head {
	flex: 0 0 auto;
	padding: 8px 10px;
	border-bottom: 1px solid var(--se-line-strong);
	font-family: var(--se-font-head);
	font-size: var(--se-size-small);
	font-weight: 600;
	color: var(--se-muted);
	white-space: nowrap;
}

/* Only what is on screen exists, inside a container of the full height. */
.se-viewport {
	flex: 1 1 auto;
	min-height: 0;
	overflow: auto;
	position: relative;
}

.se-canvas {
	position: relative;
}

.se-row--cue {
	position: absolute;
	top: 0;
	inset-inline: 0;
	padding: var(--se-row-padding) 10px;
	border-bottom: 1px solid var(--se-line);
}

.se-row--cue:hover {
	background: #f7f7f8;
}

.se-cell {
	min-width: 0;
}

.se-cell--0,
.se-cell--3,
.se-cell--4 {
	padding-top: calc(var(--se-text-padding) + 1px);
	font-variant-numeric: tabular-nums;
	color: var(--se-muted);
}

/* A cue nobody can read in the time it is on screen. */
.se-hot {
	color: var(--se-action);
	font-weight: 700;
}

.se-time {
	width: 100%;
	padding: var(--se-text-padding) 6px;
	border: 1px solid transparent;
	border-radius: 4px;
	background: transparent;
	font-family: var(--se-font-mono);
	font-size: var(--se-size-small);
	line-height: var(--se-line-height);
	font-variant-numeric: tabular-nums;
	color: var(--se-text);
}

.se-time:hover {
	border-color: var(--se-line);
}

.se-time:focus {
	background: var(--se-surface);
	border-color: var(--se-focus);
}

.se-text {
	display: block;
	width: 100%;
	padding: var(--se-text-padding) 6px;
	border: 1px solid transparent;
	border-radius: 4px;
	background: transparent;
	font: inherit;
	line-height: var(--se-line-height);
	color: var(--se-ink);
	resize: none;
	overflow: hidden;
}

.se-text:hover {
	border-color: var(--se-line);
}

.se-text:focus {
	background: var(--se-surface);
	border-color: var(--se-focus);
	outline: none;
}

.is-invalid {
	border-color: var(--se-action) !important;
	background: #fff5f5;
}

.se-action {
	min-width: 26px;
	height: 26px;
	margin-inline-end: 2px;
	padding: 0;
	border: 1px solid transparent;
	border-radius: 4px;
	background: transparent;
	color: var(--se-muted);
	font: inherit;
	font-size: 15px;
	line-height: 1;
	cursor: pointer;
	opacity: 0;
}

.se-row--cue:hover .se-action,
.se-action:focus-visible {
	opacity: 1;
}

.se-action:hover {
	border-color: var(--se-line-strong);
	color: var(--se-ink);
}

/* A cue a message points at ------------------------------------------- */

.se-row--flagged {
	box-shadow: inset -3px 0 0 var(--se-warn);
}

.se-row.is-revealed {
	animation: se-reveal 1.4s ease-out;
}

@keyframes se-reveal {
	0%,
	40% {
		background-color: #fdf1d6;
	}
	100% {
		background-color: transparent;
	}
}

/* Notices -------------------------------------------------------------- */

.se-notices:empty {
	display: none;
}

.se-notice {
	flex: 0 0 auto;
	border: 1px solid var(--se-line-strong);
	border-radius: var(--se-radius);
	background: var(--se-surface);
	padding: 10px 14px;
}

.se-notice--warning {
	border-right: 4px solid var(--se-warn);
}

.se-notice--error {
	border-right: 4px solid var(--se-action);
}

.se-notice--ok {
	border-right: 4px solid #2e7d32;
}

.se-problem-list {
	margin: 0;
	padding: 0 18px 0 0;
}

.se-problem {
	margin: 2px 0;
	font-size: var(--se-size-small);
	color: var(--se-text);
}

.se-problem__link {
	padding: 0;
	border: 0;
	background: none;
	font: inherit;
	color: var(--se-text);
	text-align: right;
	text-decoration: underline;
	text-underline-offset: 3px;
	text-decoration-color: var(--se-line-strong);
	cursor: pointer;
}

.se-problem__link:hover {
	color: var(--se-ink);
	text-decoration-color: currentColor;
}

.se-noscript {
	margin: 40px auto;
	max-width: 480px;
	text-align: center;
	color: var(--se-muted);
}

@media (prefers-reduced-motion: reduce) {
	* {
		transition-duration: 0.01ms !important;
		animation-duration: 0.01ms !important;
	}
}

/* Work area: the list and the film side by side ------------------------ */

.se-work {
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	gap: var(--se-gap);
	align-items: stretch;
}

.se-work > * {
	min-width: 0;
	min-height: 0;
}

/* The panel is as tall as what is in it, not as tall as the list beside it. */
.se-player {
	flex: 0 0 380px;
	align-self: stretch;
	max-height: 100%;
	overflow: auto;
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 10px;
	background: var(--se-surface);
	border: 1px solid var(--se-line);
	border-radius: var(--se-radius);
}

/* Until a film is loaded the frame is not worth the space it would take. */
.se-stage {
	display: none;
	position: relative;
	background: #000;
	border-radius: 4px;
	overflow: hidden;
}

.se-player.is-loaded .se-stage {
	display: block;
}

.se-video {
	display: block;
	width: 100%;
	max-height: 46vh;
}

/*
 * The subtitle over the picture, placed clear of the player's own controls.
 * It is drawn the way a player would draw it, because judging a line means
 * seeing it where the viewer will.
 */
.se-overlay {
	position: absolute;
	inset-inline: 8px;
	bottom: 46px;
	display: none;
	text-align: center;
	font-size: clamp(14px, 2.4vw, 20px);
	line-height: 1.35;
	color: #fff;
	white-space: pre-wrap;
	text-shadow: 0 0 4px #000, 0 1px 2px #000;
	pointer-events: none;
}

.se-overlay.is-showing {
	display: block;
}

.se-player__controls {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
}

.se-player__spacer {
	flex: 1 1 auto;
}

.se-clock {
	font-family: var(--se-font-mono);
	font-size: var(--se-size-small);
	color: var(--se-muted);
	font-variant-numeric: tabular-nums;
}

/* The row being worked on, and the row the film is showing. */
.se-row--cue.is-selected {
	background: #eef4fd;
}

.se-row--cue.is-current {
	box-shadow: inset 4px 0 0 var(--se-action);
}

.se-row--cue.is-current.se-row--flagged {
	box-shadow: inset 4px 0 0 var(--se-action), inset -3px 0 0 var(--se-warn);
}

@media (max-width: 900px) {
	.se-work {
		flex-direction: column;
	}

	.se-player {
		flex: 0 0 auto;
	}
}

/* The handle between the panes ----------------------------------------- */

.se-splitter {
	flex: 0 0 10px;
	align-self: stretch;
	border-radius: 999px;
	background: transparent;
	cursor: col-resize;
	position: relative;
	touch-action: none;
}

.se-splitter::before {
	content: "";
	position: absolute;
	inset: 0 4px;
	border-radius: 999px;
	background: var(--se-line);
}

.se-splitter:hover::before,
.se-splitter.is-dragging::before,
.se-splitter:focus-visible::before {
	background: var(--se-line-strong);
}

/* Closing the warnings ------------------------------------------------- */

.se-notice {
	position: relative;
	padding-inline-start: 36px;
}

.se-notice__close {
	position: absolute;
	inset-inline-start: 8px;
	top: 6px;
	width: 26px;
	height: 26px;
	padding: 0;
	border: 1px solid transparent;
	border-radius: 4px;
	background: transparent;
	color: var(--se-muted);
	font: inherit;
	font-size: 17px;
	line-height: 1;
	cursor: pointer;
}

.se-notice__close:hover {
	border-color: var(--se-line-strong);
	color: var(--se-ink);
}

.se-button--warn {
	border-color: var(--se-warn);
	color: #8a5a00;
}

.se-button--warn:hover {
	background: #fdf6e7;
}

/* Dropping ------------------------------------------------------------- */

.se-app.is-dropping .se-drop,
.se-app.is-dropping .se-work {
	outline: 2px dashed var(--se-accent);
	outline-offset: 4px;
	border-radius: var(--se-radius);
}

.se-drop__note {
	margin: 16px 0 0;
	font-size: var(--se-size-small);
	min-height: 1.2em;
}

.se-drop__note.is-waiting {
	color: #2e7d32;
}

.se-drop__note.is-rejected {
	color: var(--se-action);
}

/*
 * A rule that gives an element a display value beats the browser's own rule for
 * [hidden], so anything hidden in script stays on screen unless this is said.
 */
[hidden] {
	display: none !important;
}

/* A file name is a name, not a sentence: it keeps its own direction. */
.se-player__name {
	unicode-bidi: plaintext;
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* An empty file ------------------------------------------------------- */

.se-empty {
	padding: 48px 24px;
	text-align: center;
}

.se-empty__text {
	margin: 0 0 6px;
	font-family: var(--se-font-head);
	font-size: 17px;
	font-weight: 600;
	color: var(--se-ink);
}

.se-empty__hint {
	margin: 0 auto;
	max-width: 46ch;
	color: var(--se-muted);
	font-size: var(--se-size-small);
}

/* The page around the editor ------------------------------------------ */

.se-bar__brand {
	display: flex;
	align-items: center;
	text-decoration: none;
	color: inherit;
}

.se-bar__logo {
	display: block;
	height: 30px;
	width: auto;
}

.se-nav {
	display: flex;
	align-items: center;
	gap: 18px;
	margin-inline-start: 22px;
}

.se-nav__link {
	color: var(--se-text);
	text-decoration: none;
	font-size: var(--se-size-base);
}

.se-nav__link:hover {
	color: var(--se-ink);
	text-decoration: underline;
	text-underline-offset: 4px;
}

.se-foot {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 16px;
	flex-wrap: wrap;
	padding: 6px 16px;
	background: var(--se-surface);
	border-top: 1px solid var(--se-line);
	font-size: var(--se-size-small);
	color: var(--se-muted);
}

.se-foot__link {
	color: var(--se-muted);
	text-decoration: none;
}

.se-foot__link:hover {
	color: var(--se-ink);
	text-decoration: underline;
	text-underline-offset: 3px;
}

.se-foot__note {
	margin-inline-start: auto;
}

/*
 * Two modes for the same element. Before a file is opened this is a page that
 * scrolls; once one is open it is an application that fills what is left of the
 * window and never scrolls as a whole.
 */
.se-main {
	display: block;
	overflow: auto;
	padding: 0;
}

.se-main--editing {
	display: flex;
	flex-direction: column;
	overflow: hidden;
	padding: 16px;
}

.se-landing {
	max-width: 1000px;
	margin: 0 auto;
	padding: 40px 20px 56px;
}

.se-landing__title {
	margin: 0 0 10px;
	font-family: var(--se-font-head);
	font-size: clamp(26px, 4vw, 38px);
	font-weight: 700;
	line-height: 1.2;
	color: var(--se-ink);
	text-align: center;
}

.se-landing__lead {
	margin: 0 auto 28px;
	max-width: 62ch;
	text-align: center;
	font-size: 17px;
	color: var(--se-muted);
}

.se-landing .se-drop {
	margin: 0 auto;
}

/* The written part of the page, which lives in WordPress. */
.se-prose {
	margin-top: 56px;
}

.se-prose h2 {
	margin: 40px 0 12px;
	font-family: var(--se-font-head);
	font-size: 22px;
	font-weight: 700;
	color: var(--se-ink);
}

.se-prose h3 {
	margin: 0 0 4px;
	font-family: var(--se-font-head);
	font-size: 16px;
	font-weight: 600;
	color: var(--se-ink);
}

.se-prose p {
	margin: 0 0 12px;
	max-width: 72ch;
}

.se-prose a {
	color: var(--se-action);
}

.se-cards {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
	gap: 14px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.se-cards li {
	padding: 16px;
	background: var(--se-surface);
	border: 1px solid var(--se-line);
	border-radius: var(--se-radius);
}

.se-cards p {
	margin: 0;
	font-size: var(--se-size-small);
	color: var(--se-muted);
}
