
$cell-background: white !default;
$cell-border: 1px solid #ccc !default;
$cell-border-radius: $border-radius !default;
$cell-color: inherit !default;

$cell-title-cover-border: true !default;

$cell-entry-color: $link-color !default;
$cell-entry-font-weight: normal !default;
$cell-entry-border-color: #ccc !default;
$cell-entry-border: 1px solid $cell-entry-border-color !default;
$cell-entry-hover-color: inherit !default;
$cell-entry-hover-background: #eee !default;

$footer-menucell-separator: none !default;

// $cell-entry-hover-effect: effect applied when hovering an entry link in a
// cell; possible values are:
//  none: nothing special, light gray background;
//  left-to-right: background expands from left to right;
//  right-to-left: " from right to left;
//  top-to-bottom: " from top to bottom;
//  bottom-to-top: " from bottom to top;
//  middle-to-edges: horizontally, from the middle to the edges.
$cell-entry-hover-effect: none !default;

// $cell-image-position: define where is set the associated image (in
// "forms of category"; possible values are:
//  top: top of the cell
//  after-title: after the title (default)
$cell-image-position: after-title !default;

// $cell-image-padding: define padding of cell image.
$cell-image-padding: 0.5rem !default;

$cell-open-foldable-icon: "\f107" !default;  // angle-down
$cell-close-foldable-icon: "\f106" !default;  // angle-up

// Columns gutters
@media screen and ($min-desktop-viewport) {
	.column .a2-block,
	.column .cell,
	.block {
		margin-left: #{$columns-gutter / 2};
		margin-right: #{$columns-gutter / 2};
	}
	.column:first-child .block,
	.column:first-child .a2-block,
	.column:first-child .cell { margin-left: 0; }
	.column:last-child .block,
	.column:last-child .a2-block,
	.column:last-child .cell { margin-right: 0; }
}

.a2-block {
	margin: 4em auto;
	max-width: 45em;
	& form, & p {
		margin: 1em 0.5em;
	}
	p {
		line-height: 1.4;
	}
	@media screen and ($max-mobile-viewport) {
		margin: 0 auto;
	}
}

div#sidebar + div#columns {
	div.a2-block {
		margin: 0 0 3em 0;
	}
	.methods2 .a2-block {
		margin-right: 2em;
	}
}

%cell {
	text-align: left;
	background: $cell-background;
	color: $cell-color;
	border: $cell-border;
	border-radius: $cell-border-radius;
}

div.a2-continue,
div#services > ul > li,
div.a2-block,
.gru-content .cell,
.block {
	@extend %cell;
}

.column div.a2-block,
.gru-content div.cell,
.block {
	margin-top: 0;
	margin-bottom: 10px;
	& h2 + div,
	.cell--body {
		padding: 1rem;
		& p.empty-message {
			margin: 0;
		}
	}
	& h2 + div.links-list {
		padding: 0;
	}
}

.gru-content .cell.wcsformsofcategorycell {
	h2 ~ div.intro {
		padding: 1rem;
	}
}

.gru-content div.cell.categoriescell div div,
div#services > ul > li > strong {
	padding: 0;
	margin: 0;
}

.gru-content .tracking-code-input-cell {
	form {
		> p:first-child {
			margin-top: 0;
		}
		input, button {
			vertical-align: middle;
		}
	}
}

div#rub_service div.category h3,
.gru-content div.a2-block h2,
.gru-content .block h2,
div.links-list h2,
div#services > ul > li > strong > a,
.gru-content div.textcell h2:first-child,
.gru-content div.cell h2:first-child {
	@extend %title;
	position: relative;
	@if $cell-title-cover-border == true {
		margin: #{extract-width($cell-border) * -1};
	}

	@if is-positive-number($cell-border-radius)  {
		// make sure cell title don't overflow the cell radius
		border-radius: $cell-border-radius;
		&:not(:only-child) {
			border-bottom-left-radius: 0;
			border-bottom-right-radius: 0;
		};
	}
}

div.links-list p {
	margin: 1em;
}

%cell-links-list {
	padding: 0;
	margin: 0;
	list-style: none;
	position: relative;
	z-index: 0;

	& > li:not(:last-child) {
		border-bottom: $cell-entry-border;
	}
	& > li > a {
		display: flex;
		align-items: baseline;

		flex-wrap: wrap;
		padding: 1rem;
		color: $cell-entry-color;
		font-weight: $cell-entry-font-weight;
		position: relative;

		&:hover {
			text-decoration: none;
			color: $cell-entry-hover-color;
			@if $cell-entry-hover-effect == none {
				background-color: $cell-entry-hover-background;
			}
		}

		@if $cell-entry-hover-effect != none {
			transition: background-size 0.3s ease;

			$pos: left;
			$size: 0%;
			$hover-size: 100%;
			@if $cell-entry-hover-effect == right-to-left {
				$pos: right;
			} @else if $cell-entry-hover-effect == top-to-bottom {
				$pos: top;
				$size: 100% 0%;
				$hover-size: 100% 100%;
			} @else if $cell-entry-hover-effect == bottom-to-top {
				$pos: bottom;
				$size: 100% 0%;
				$hover-size: 100% 100%;
			} @else if $cell-entry-hover-effect == middle-to-edges {
				$pos: center;
			}
			background-image: linear-gradient(
				$cell-entry-hover-background 0,
				$cell-entry-hover-background 100%
			);
			background-repeat: no-repeat;
			background-size: $size;
			background-position: $pos;

			&:hover {
				background-size: $hover-size;
			}
		}
	}

	.add-more-items--button {
		display: block;
		padding: 0.5rem 1rem;
		cursor: pointer;
		text-align: center;
	}

	li div.description {
		padding: 0 1rem;
		font-size: 90%;
		color: #666;
		p {
			margin-top: 0;
			margin-bottom: 0.7em;
		}
	}

	@if is-positive-number($cell-border-radius)  {
		// make sure last link don't overflow the cell radius
		> li:last-child a:only-child {
			border-bottom-left-radius: $cell-border-radius;
			border-bottom-right-radius: $cell-border-radius;
		}
		// make sure first link don't overflow the cell radius
		> li:first-child:not(.more-items--item) a {
			border-top-left-radius: $cell-border-radius;
			border-top-right-radius: $cell-border-radius;
		}
		// BUT don't apply border-radius on not last item of sub-list links
		li:not(:last-child) li a:only-child {
			border-radius: 0;
		}
		// BUT don't apply top border-radius on first link to sub-list
		li li:first-child a {
			border-top-left-radius: 0;
			border-top-right-radius: 0;
		}
	}
}

div#rub_service div.category ul,
div#services > ul > li > ul,
div#account-management ul,
div.links-list ul,
div.menucell ul,
div.wcsformcell,
div.categoriescell ul,
div.wcsformsofcategorycell ul,
div.wcscurrentdraftscell ul,
div.wcscurrentformscell ul {
	@extend %cell-links-list;
}

.gru-content div.link-list-cell.has-asset-picture,
.gru-content div.wcsformsofcategorycell.has-asset-picture {
	picture img {
		max-width: 100%;
		display: block;
		padding: $cell-image-padding;
	}
	@if $cell-image-position == top {
		> div {
			display: flex;
			flex-direction: column;
			picture {
				order: -1;
				img {
					border-radius: $cell-border-radius $cell-border-radius 0 0;
				}
				@if $cell-title-cover-border == true {
					margin: #{extract-width($cell-border) * -1};
				}
			}
			> h2:first-child {
				border-radius: 0;
			}
		}
	}
}

div.list-of-forms {
	span.form-number {
		flex-grow: 1;

		margin-right: 1rem;
		opacity: 0.76;
		font-size: 80%;
	}
	span.form-status {
		margin-right: 0;
		margin-left: auto;
	}
	span.form-title {
		margin-right: 1rem;
	}
}

div.cell {
	div.intro {
		p {
			margin: 0;
		}
		p + p {
			margin-top: 0.7em;
		}
	}
	@extend .clearfix;
}

.gru-content div.cell {
	&.no-bottom-margin {
		margin-bottom: 0;
		border-radius: $cell-border-radius $cell-border-radius 0 0;
		border-bottom: 0;
		p:last-child {
			margin-bottom: 0;
			padding-bottom: 0.7em;
		}
		ul > li:last-child {
			border-bottom: $cell-entry-border;

			@if is-positive-number($cell-border-radius) {
				> a {
					border-radius: 0;
				}
			}
		}
		+ div {
			margin-top: 0;
			border-radius: 0 0 $cell-border-radius $cell-border-radius;
			border-top: 0;
			&.no-bottom-margin {
				border-radius: 0;
			}
			p:first-child {
				margin-top: 0;
				padding-top: 0.7em;
			}
		}
	}
	div.textcell {
		/* don't include margins/borders for textcells embedded in
		 * other cells (via extra placeholders) */
		border: 0;
		margin-left: 0;
		margin-right: 0;
		p, h3, h4, h5 {
			margin-left: 0;
			margin-right: 0;
		}
	}
}

div.menucell li li {
	border-bottom: none;
	border-top: $cell-entry-border;
	a {
		padding-left: 3em;
		font-size: 90%;
	}
}

div.searchcell {
	form {
		position: relative;
		display: flex;
		padding: 1em;
		input {
			flex: 1;
			margin: 0;
			margin-right: 1rem;
		}
		button {
			margin-right: 0;
		}
		&::after {
			content: "";
			display: block;
			position: absolute;
			bottom: 0;
			left: 0;
			height: 3px;
			background: #aaa;
			width: 0%;
		}
		&.searching::after {
			-webkit-animation: cell-loading-pulse 0.5s linear infinite alternate;
			animation: cell-loading-pulse 0.5s linear infinite alternate;
		}
	}
}

#sidebar div.searchcell {
	form {
		display: block;
		input {
			width: 100%;
			margin-bottom: 0.2em;
		}
	}
}

div.cell div.loading {
	color: #444;
	position: relative;
}

@-webkit-keyframes cell-loading-pulse {
	to { width: 100%; }
}

@keyframes cell-loading-pulse {
	to { width: 100%; }
}

div.cell div.loading span {
	position: relative;
	z-index: 10;
	padding: 0.3rem;
	display: inline-block;
}

div.cell div.loading::after {
	content: "";
	position: absolute;
	z-index: 0;
	left: 0;
	width: 0px;
	background: #eee;
	height: 100%;
	border-radius: $cell-border-radius;
	-webkit-animation: cell-loading-pulse 2s linear infinite alternate;
	animation: cell-loading-pulse 2s linear infinite alternate;
}

div.cell div.loading.error-loading {
	border-radius: $cell-border-radius;
	background: #f44;
}

div.cell div.loading.error-loading::after {
	content: none;
}

.gru-content div.cell.shown-because-admin {
	h2 {
		background: transparent;
	}
	opacity: 0.5;
	background-image: repeating-linear-gradient(-45deg, #eee 0px, #eee 14px, transparent 15px, transparent 30px);
	&:hover {
		h2 {
			background: inherit;
		}
		opacity: 1;
		background-image: inherit;
	}
}

// Lingo basket cell
.lingo-basket-cell {
	.gru-content &.cell h2 + &--content {
		padding: 0;
	}
	&--regie-name {
		padding-left: 1rem;
		padding-right: 1rem;
	}
	&--list {
		list-style: none;
		margin: 0;
		padding: 0;
	}
	&--item {
		padding: 1rem;
		border-bottom: $cell-entry-border;
		display: flex;
		flex-wrap: wrap;
		align-items: baseline;
		&-label {
			overflow: hidden;
		}
		&-price {
			text-align: right;
			flex: 1 0 5rem;
		}
		&-actions {
			@media ($max-mobile-viewport) {
				flex: 1 0 100%;
			}
			@media ($min-desktop-viewport) {
				margin-left: 1em;
			}
		}
		&-remove {
			text-align: right;
		}
		&-pay {
			@extend .pk-button;
		}
	}
	&--total {
		padding-left: 1rem;
		padding-right: 1rem;
		text-align: right;
	}
}

div.lingobasketcell button, div.newsletterscell button,
div.lingobasketcell input[type=submit], div.newsletterscell input[type=submit] {
	margin: 0 1em 1em 1em;
}

// newsletters
.newsletterscell table {
	width: 100%;
	font-size: 0.9em;
	margin: 0.5em 0;

	thead td, tbody td {
		padding-left: 5px;
	}
	thead td {
		font-weight: bold;
		text-align: center;
	}

	tbody td:nth-child(1) {
		text-align: left;
	}
	tbody td {
		text-align: center;
	}
}

div.feedcell h3 {
	margin: 0 0 0.3em 0;
}

div.feedcell div.feed-content div,
div.feedcell div.feed-content p {
	margin: 0.3em 0 1em 0;
}

div.feedcell img {
	max-width: 100%;
}

// booking calendar

div.bookingcalendar {
	p.paginator {
		position: relative;
		margin-top: 0;
		text-align: center;
		span.previous, span.next {
			opacity: 0.5;
		}
		.previous {
			position: absolute;
			left: 0;
		}
		.next {
			position: absolute;
			right: 0;
		}
	}
	table th {
		text-align: center;
		height: 2.2em;
	}
	table tbody th {
		padding-right: 0.7em;
	}
	table td {
		border: 1px solid #ddd;
		position: relative;
		input[type=checkbox] {
			position: relative;
			display: block;
			width: 100%;
			z-index: 10;
		}
		input[type=checkbox] + label {
			position: absolute;
			z-index: 2;
			top: 0;
			left: 0;
			width: 100%;
			height: 100%;
			background: white;
			transition: background 0.3s ease;
		}
		input[type=checkbox]:disabled + label {
			background: #ccc;
		}
		&.active-column input,
		&.active-column label {
			pointer-events: none;
		}
		&.active-column.clickable input,
		&.active-column.clickable label {
			pointer-events: auto;
		}
		input[type=checkbox]:checked + label {
			background: #00c500;
		}
		&.absent {
			background: #eee;
		}
		&.unavailable {
			background: #c50000;
		}
	}
	table {
		margin-bottom: 1em;
	}
}

// login page

#registration-blocks.methods2 > .a2-block,
#login-page.methods2 > .block {
	width: 50%;
	width: calc(50% - 2em);
	margin: 0;
	margin-right: 2em;
	float: left;
}

#registration-blocks.methods3 > .a2-block,
#login-page.methods3 > .block {
	width: 33%;
	width: calc(33% - 2em);
	margin: 0;
	margin-right: 2em;
	float: left;
}

#registration-blocks > .a2-block > div,
#login-page > .block > div {
	padding: 1em;
}

#registration-blocks.methods2 > .a2-block,
#registration-blocks.methods3 > .a2-block,
#login-page.methods2 > .block,
#login-page.methods3 > .block {
	@media screen and ($max-mobile-viewport) {
		width: auto;
		float: none;
		margin: 0.7em;
	}
}

div.cell hr {
	width: 80%;
}

.gru-content div.tipipaymentformcell > div > div {
	padding: 0 1em;
	form {
		// prevent grid display to set those <input> to take the whole
		// width
		#exer, #idligne, #idpce,
		#rolrec, #roldeb, #roldet,
		#montant_euros, #montant_cents {
			width: auto;
		}
	}
}

// family cell styles

div.familyinfoscell {
	h3 {
		padding: 5px 0;
		margin: 5px 0;
	}
	div.address {
		margin: 0.7em 0;
		h4 {
			margin: 0;
		}
	}
	div.family-data {
		padding-bottom: 1.5em;
		border-bottom: $title-border-bottom;
	}
	div.family_unlink {
		text-align: right;
	}
	div.family_members {
		display: flex;
		justify-content: space-between;
		@media screen and ($max-mobile-viewport) {
			flex-direction: column;
		}
	}
	div.family_adults, div.family_children {
		width: 48%;
		@media screen and ($max-mobile-viewport) {
			width: auto;
		}
		> div {
			border-bottom: $title-border-bottom;
			padding-bottom: 0.7em;
			margin: 0.7em 0;
		}
		.name {
			font-size: 115%;
		}
	}
	p {
		margin: 0;
		padding: 0;
		span.label {
			font-weight: bold;
		}
	}
}

// support foldable cells
div.cell {
	&.foldable {
		> div > h2:first-child {
			&::after {
				font-family: FontAwesome;
				content: $cell-close-foldable-icon;
				position: absolute;
				right: 1em;
			}
			cursor: pointer;
		}
		> div > h2:first-child,
		> div > picture {
			cursor: pointer;
		}
	}
	&.foldable.folded {
		> div > h2:first-child {
			&::after {
				content: $cell-open-foldable-icon;
			}

			& ~ *:not(picture) {
				display: none;
			}
		}
	}
}

#footer .menucell {
	/* custom style for menu cells in footer, center links on a single line */
	text-align: center;
	li {
		display: inline-block;
		border: none;
		border-right: $footer-menucell-separator;
		&:last-child {
			border-right: none;
		}
		a {
			border-radius: 0;
			border: none;
			color: text-color($footer-background);
			padding: 0.5rem 1rem;
			&:hover {
				text-decoration: $link-hover-decoration;
				background: none;
				&::after {
					content: none;
				}
			}
		}
	}
}

div.gallerycell {
	div.gallery {
		text-align: center;
		img {
			max-width: 100%;
			border: 1px solid #888;
		}
	}
}

.gru-content div.cell div.cell-items-pagination {
	padding: 1rem;
	.cell-items-pagination-next {
		float: right;
		margin-right: 0;
	}
}

.profile-cell .profile {
	@extend #profile;
}

.wcs-card-infos-cell img {
	max-width: 100%;
}

.empty-cell {
	display: none !important;
}

 div.links-list ul > li.latest-page-updates-cell--item a {
	display: block;
}
