/* ==========================================================================
   Fonts
   ========================================================================== */

@font-face {
	font-family: "Ashurit";
	src: url("fonts/Ashurit.ttf") format("truetype");
	font-weight: normal;
	font-style: normal;
	font-display: swap;
}

@font-face {
	font-family: "SBL Hebrew";
	src: url("fonts/SBL_Hebrew.ttf") format("truetype");
	font-weight: normal;
	font-style: normal;
	font-display: swap;
}

/* ==========================================================================
   Theme and font variables (set via data attributes on <html>, see master.js)

   The two fonts are very different in size at the same font-size: SBL Hebrew
   is about 1.32x larger than Ashurit (measured from the glyph outlines). The
   variables below even that out so both fonts look equally large.
   --hebrew-scale       multiplier for the Name on name.html
   --hebrew-hero-line-height  line box of that Name (fonts have different spare space below)
   --grid-fill          font-size as a share of the grid cell width
   --meditation-*       limits for the fullscreen modal
   --hebrew-stroke      Ashurit has hairline details (~1px when small) that look
                        blurry, so a very thin outline firms them up
   ========================================================================== */

:root {
	--hebrew-font: "Ashurit", "SBL Hebrew", serif;
	--hebrew-scale: 1.28;
	--hebrew-hero-line-height: 0.72;
	--hebrew-stroke: 0.004em;
	--grid-fill: 0.6;
	--meditation-max-width: 64vw;
	--meditation-max-height: 55dvh;
}

:root[data-font="sbl-hebrew"] {
	--hebrew-font: "SBL Hebrew", "Ashurit", serif;
	--hebrew-scale: 0.97;
	--hebrew-hero-line-height: 0.85;
	--hebrew-stroke: 0;
	--grid-fill: 0.43;
	--meditation-max-width: 46vw;
	--meditation-max-height: 41.7dvh;
}

@media (min-width: 992px) {
	:root {
		--meditation-max-height: 48dvh;
	}

	:root[data-font="sbl-hebrew"] {
		--meditation-max-height: 36.5dvh;
	}
}

[data-bs-theme="dark"] {
	--bs-body-bg: #222;
	--bs-body-bg-rgb: 34, 34, 34;
	--bs-body-color: #fff;
	--bs-body-color-rgb: 255, 255, 255;
}

/* ==========================================================================
   Base
   ========================================================================== */

html,
body {
	margin: 0;
	padding: 0;
	width: 100%;
	min-height: 100%;
}

body {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	min-height: 100dvh;
}

main {
	flex: 1 0 auto;
}

/* ==========================================================================
   Navigation
   ========================================================================== */

.nav-menu-list {
	min-width: 18rem;
	max-height: 70dvh;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.nav-menu-list .dropdown-item {
	padding-top: 0.55rem;
	padding-bottom: 0.55rem;
	white-space: normal;
}

.nav-menu-settings {
	min-width: 17rem;
}

/* On phones the menus become full-width sheets under the navbar */
@media (max-width: 575.98px) {
	.navbar .dropdown {
		position: static;
	}

	.navbar .dropdown-menu {
		left: 0;
		right: 0;
		width: 100%;
		margin-top: 0;
		border-radius: 0;
		border-left: 0;
		border-right: 0;
	}

	.navbar .nav-menu-list {
		max-height: calc(100dvh - 3.5rem);
	}

	/* Settings stays compact and right-aligned so the page behind stays visible */
	.navbar .nav-menu-settings {
		left: auto;
		width: auto;
		border-left: var(--bs-dropdown-border-width) solid var(--bs-dropdown-border-color);
	}
}

/* ==========================================================================
   Hebrew text
   ========================================================================== */

.hebrew {
	font-family: var(--hebrew-font);
	direction: rtl;
	unicode-bidi: isolate;
	line-height: 1.2;
	text-rendering: geometricPrecision;
	-webkit-text-stroke: var(--hebrew-stroke) currentColor;
}

.hebrew-trigger {
	display: inline-block;
	margin: 0;
	padding: 0.1em 0.3em;
	border: 0;
	background: none;
	color: inherit;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.hebrew-trigger:focus-visible {
	outline: 2px solid var(--bs-primary);
	outline-offset: 4px;
	border-radius: var(--bs-border-radius);
}

.hebrew-hero {
	font-size: calc(clamp(5rem, 28vw, 12rem) * var(--hebrew-scale));
	/* Tighter than the font's own line box to shrink the gap to the title */
	line-height: var(--hebrew-hero-line-height);
}

.hebrew-tetragrammaton {
	font-size: clamp(6rem, 30vw, 16rem);
}

/* ==========================================================================
   Start page
   ========================================================================== */

.start-page {
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	text-align: center;
	padding-top: 1rem;
	padding-bottom: 3rem;
}

/* ==========================================================================
   Name list (in the List menu)
   ========================================================================== */

.name-number {
	display: inline-block;
	min-width: 2.25rem;
	text-align: end;
	margin-inline-end: 0.5rem;
	color: var(--bs-secondary-color);
	font-variant-numeric: tabular-nums;
}

.name-emoji {
	display: inline-block;
	min-width: 2rem;
	margin-inline-end: 0.5rem;
	text-align: center;
}

/* ==========================================================================
   Name grid
   ========================================================================== */

/* Bootstrap's row-cols stops at 6, so add an 8-column variant for large screens */
@media (min-width: 992px) {
	.row-cols-lg-8 > * {
		flex: 0 0 auto;
		width: 12.5%;
	}
}

/* Each column is a size container, so the letters can scale with the cell width */
.name-grid > * {
	container-type: inline-size;
}

/* Cells share their borders: each cell overlaps its neighbour by one border width */
.name-grid-item {
	position: relative;
	display: flex;
	justify-content: center;
	align-items: center;
	aspect-ratio: 3 / 2;
	margin-inline-end: -1px;
	margin-block-end: -1px;
	padding: 0;
	border: 1px solid var(--bs-border-color);
	border-radius: 0;
	background: none;
	color: var(--bs-body-color);
	text-decoration: none;
	-webkit-tap-highlight-color: transparent;
}

.name-grid-item:hover,
.name-grid-item:focus-visible {
	z-index: 1;
	border-color: var(--bs-primary);
	background-color: var(--bs-tertiary-bg);
	color: var(--bs-body-color);
}

.name-grid-letters {
	font-size: calc(100cqw * var(--grid-fill));
	line-height: 1;
}

.name-grid-number {
	position: absolute;
	top: 0.2rem;
	right: 0.3rem;
	font-size: 0.625rem;
	line-height: 1;
	font-variant-numeric: tabular-nums;
	color: var(--bs-secondary-color);
	opacity: 0.8;
}

/* ==========================================================================
   Name page
   ========================================================================== */

.name-page {
	max-width: 46rem;
}

.name-description {
	text-align: start;
	line-height: 1.7;
}

/* ==========================================================================
   Meditation modal (fullscreen)
   ========================================================================== */

.meditation-modal .modal-content {
	border: 0;
	border-radius: 0;
	background-color: var(--bs-body-bg);
}

.meditation-close {
	display: flex;
	justify-content: center;
	align-items: center;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	color: var(--bs-body-color);
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	user-select: none;
	-webkit-user-select: none;
}

.meditation-text {
	/* Sized by the smaller of width and height so it fits portrait and landscape */
	font-size: min(var(--meditation-max-width), var(--meditation-max-height));
	white-space: nowrap;
	/* Already crisp at this size */
	-webkit-text-stroke: 0;
}

/* ==========================================================================
   Settings (menu)
   ========================================================================== */

.settings-menu .form-check {
	padding-top: 0.25rem;
	padding-bottom: 0.25rem;
}

.settings-menu .form-check-label {
	display: block;
	min-width: 8rem;
	padding-top: 0.1rem;
	padding-bottom: 0.1rem;
}

.font-sample {
	font-size: 1.75rem;
	line-height: 1.2;
}

.font-sample-ashurit {
	font-family: "Ashurit", serif;
}

.font-sample-sbl-hebrew {
	font-family: "SBL Hebrew", serif;
}
